Re: connection already closed error
От | AM |
---|---|
Тема | Re: connection already closed error |
Дата | |
Msg-id | AEA6CD00-36F7-40C0-9D22-F91BDC37C2E7@themactionfaction.com обсуждение исходный текст |
Ответ на | Re: connection already closed error (Daniele Varrazzo <daniele.varrazzo@gmail.com>) |
Список | psycopg |
On Oct 18, 2011, at 11:11 AM, Daniele Varrazzo wrote: > > >> Would a possible solution be to change twistedpg.py to: > >> def close(self): >> try: >> _2connection.close(self) >> except psycopg2.InterfaceError: >> pass > > It seems so. You could also use "if not self.closed: > _2connection.close(self)" (if you have this attribute exposed... why > not just self.close()?). However, I think there is not really a reason > for which conn.close() should raise an error on a closed connection: > it is an idempotent method. > > /me looks at the dbapi... > > uhm, it doesn't explicitly require that. I think a more robust close() > should just return if the connection is closed. It shouldn't raise > exceptions, as in turn PQfinish doesn't. Oh yes, I see: we used to > execute a ROLLBACK on close() so we needed the connection to be open > to be properly closed... but we don't do this anymore. Currently we do > little more than calling PQfinish, which never fails (well, not > politely at least). > > Fog, whaddyathink: "conn.close(); conn.close()" should raise an > exception or should just return? To mimic python's standard close(), it would indeed need to be idempotent. Cheers, M
В списке psycopg по дате отправления: