On Fri, Dec 29, 2006 at 09:45:35AM +0200, Dan Pascu wrote:
> Trying to reconnect forever or for long periods of time is a bad thing. 

   Agree.

> Attached is a patch that fixes this in a better way. It still allows 
> reconnects if the database connection was lost because of a server 
> restart or the connection being closed because it was idle too long, but 
> will allow the application to make decisions on its own if the database 
> is down for good and cannot be reconnected.

   Thank you!

> +        for c in range(0, 3):
>              try:
>                  if self.need_unicode:
>                      # For MysqlDB 1.2.1 and later, we go
> @@ -88,7 +100,9 @@
>                  else:
>                      return cursor.execute(query)
>              except MySQLdb.OperationalError, e:
> -                if e.args[0] == 2013: # SERVER_LOST error
> +                if e.args[0] in (2006, 2013): # SERVER_GONE or SERVER_LOST 
> error
> +                    if c == 2:
> +                        raise OperationalError(ErrorMessage(e))

   I think I can move this "if...raise" out of the loop to "else" clause.

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            [EMAIL PROTECTED]
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to