[gozerbot] push by bth...@gmail.com - try to reconnect is the mysql connection went away on 2011-08-07 14:35 GMT

3 views
Skip to first unread message

goze...@googlecode.com

unread,
Aug 7, 2011, 10:40:50 AM8/7/11
to gozerbo...@googlegroups.com
Revision: 939cadb100f3
Author: Bart Thate <bth...@gmail.com>
Date: Sun Aug 7 07:20:01 2011
Log: try to reconnect is the mysql connection went away
http://code.google.com/p/gozerbot/source/detail?r=939cadb100f3

Modified:
/gozerbot/database/alchemy.py

=======================================
--- /gozerbot/database/alchemy.py Fri Aug 5 14:18:55 2011
+++ /gozerbot/database/alchemy.py Sun Aug 7 07:20:01 2011
@@ -251,18 +251,23 @@
try:
res = dotransaction(*args, **kwargs)
return res
+ except sqlalchemy.exc.OperationalError, ex:
+ if 'server has gone away' in str(ex):
+ rlog(10, 'alchemy', 'mysql server has gone away')
+ startmaindb()
except Exception, ex:
- if "rollback" in str(ex): Session.rollback()
+ if "rollback" in str(ex): rlog(10, 'database', 'rolling back
the session') ; Session.rollback()
else: raise
- logging.warn("transaction failed: %s - retyring .." % str(ex))
- try:
- res = dotransaction(*args, **kwargs)
- try: Session.commit()
- except Exception, ex: Session.rollback() ; raise
- return res
- except Exception, ex:
- Session.rollback()
- handle_exception()
+ logging.warn("transaction failed: %s - retyring .." % str(ex))
+ try:
+ res = dotransaction(*args, **kwargs)
+ try: Session.commit()
+ except Exception, ex: Session.rollback() ; raise
+ return res
+ except Exception, ex:
+ rlog(10, 'database', 'rolling back the session - giving up
- %s failed due to %s' % (str(args), str(ex)))
+ Session.rollback()
+ handle_exception()

return transaction

Reply all
Reply to author
Forward
0 new messages