Hi all,
I am using python2.6 with twisted 10.1.0 and psycopg2 2.2.1. We are also using pgpooler with transaction pool mode set.
Iam using the twisted ConnectionPool and twistedpg.py, which is:
from psycopg2 import *
from psycopg2 import _psycopg as _2psycopg
from psycopg2.extensions import connection as _2connection
from psycopg2.extras import RealDictCursor
del connect
def connect(*args, **kwargs):
kwargs['connection_factory'] = connection
return _2psycopg.connect(*args, **kwargs)
class connection(_2connection):
def cursor(self):
return _2connection.cursor(self, cursor_factory=RealDictCursor)
I connect to pgpooler with:
dbpool = ConnectionPool("twistedpg", self.DSN, cp_reconnect=cp_reconnect, cp_openfun = self.connect_func, **kwords)
I am getting this error when we restart pgpool:
Traceback (most recent call last):
File "/usr/lib/python2.6/dist-packages/twisted/python/context.py", line 37, in callWithContext
return func(*args,**kw)
File "/usr/lib/python2.6/dist-packages/twisted/enterprise/adbapi.py", line 436, in _runInteraction
conn.rollback()
File "/usr/lib/python2.6/dist-packages/twisted/enterprise/adbapi.py", line 65, in rollback
self._pool.disconnect(self._connection)
File "/usr/lib/python2.6/dist-packages/twisted/enterprise/adbapi.py", line 412, in disconnect
self._close(conn)
--- <exception caught here> ---
File "/usr/lib/python2.6/dist-packages/twisted/enterprise/adbapi.py", line 420, in _close
conn.close()
psycopg2.InterfaceError: connection already closed
This error keeps repeating for about 3 hours, even though the pooler was back up in running within a minute.
Would a possible solution be to change twistedpg.py to:
from psycopg2 import *
from psycopg2 import _psycopg as _2psycopg
from psycopg2.extensions import connection as _2connection
from psycopg2.extras import RealDictCursor
del connect
def connect(*args, **kwargs):
kwargs['connection_factory'] = connection
return _2psycopg.connect(*args, **kwargs)
class connection(_2connection):
def cursor(self):
return _2connection.cursor(self, cursor_factory=RealDictCursor)
def close(self):
try:
_2connection.close(self)
except psycopg2.InterfaceError:
pass
Thanks for all the help,
Mark