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