Re: connection already closed error - Mailing list psycopg
From | Mark Theisen |
---|---|
Subject | Re: connection already closed error |
Date | |
Msg-id | 7197F80C5AE6E943AF2CC4067B22FBD4BD0DD3F063@OMALINMAIL01.lindsaymfg.local Whole thread Raw |
In response to | connection already closed error (Mark Theisen <mark.theisen@digitecinc.com>) |
List | psycopg |
A note of clarification. We are using pgbouncer instead of pgpool. Sorry about the confusion. Thanks, Mark ________________________________________ From: psycopg-owner@postgresql.org [psycopg-owner@postgresql.org] On Behalf Of Mark Theisen [mark.theisen@digitecinc.com] Sent: Tuesday, October 18, 2011 9:32 AM To: psycopg@postgresql.org Subject: [psycopg] connection already closed error 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 -- Sent via psycopg mailing list (psycopg@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/psycopg