Modified:
/bin/gozerbot
/gozerbot/database/alchemy.py
=======================================
--- /bin/gozerbot Tue Jul 19 13:03:08 2011
+++ /bin/gozerbot Tue Aug 9 11:26:09 2011
@@ -6,6 +6,8 @@
__copyright__ = 'this file is in the public domain'
+import warnings
+warnings.simplefilter("ignore")
import traceback, sys, os, socket
=======================================
--- /gozerbot/database/alchemy.py Sun Aug 7 07:20:01 2011
+++ /gozerbot/database/alchemy.py Tue Aug 9 11:26:09 2011
@@ -53,7 +53,8 @@
created.append(plugname)
if not base:
base = Base
- base.metadata.create_all()
+ try: base.metadata.create_all()
+ except Exception, ex: rlog(10, 'alchemy', 'problem creating %s
tables: %s' % (str(base), str(ex)))
else:
rlog(10, 'alchemy', '%s tables already created' % plugname)
@@ -114,7 +115,7 @@
rlog(10, 'alchemy', 'starting database')
# create engine
- engine = create_engine(dburi, strategy='threadlocal', pool_recycle=900)
+ engine = create_engine(dburi, strategy='threadlocal',
pool_recycle=3600)
# setup metadata and session
if not base:
@@ -252,11 +253,13 @@
res = dotransaction(*args, **kwargs)
return res
except sqlalchemy.exc.OperationalError, ex:
+ rlog(10, 'alchemy', 'rolling back the session')
+ Session.rollback()
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): rlog(10, 'database', 'rolling back
the session') ; Session.rollback()
+ if "rollback" in str(ex): rlog(10, 'alchemy', 'rolling back
the session') ; Session.rollback()
else: raise
logging.warn("transaction failed: %s - retyring .." % str(ex))
try:
@@ -265,7 +268,7 @@
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)))
+ rlog(10, 'alchemy', 'rolling back the session - giving up - %s
failed due to %s' % (str(args), str(ex)))
Session.rollback()
handle_exception()
@@ -328,6 +331,8 @@
try:
return douser(userhost)
except sqlalchemy.exc.OperationalError, ex:
+ rlog(10, 'alchemy', 'rolling back the session')
+ Session.rollback()
if 'server has gone away' in str(ex):
rlog(10, 'alchemy', 'mysql server has gone away')
startmaindb()
@@ -354,6 +359,8 @@
rollback(session)
except sqlalchemy.exc.OperationalError, ex:
+ rlog(10, 'alchemy', 'rolling back the session')
+ Session.rollback()
if 'server has gone away' in str(ex):
rlog(10, 'alchemy', 'error: %s' % str(ex))
startmaindb()