[DB-SIG] conn.close() idempotence

Federico Di Gregorio fog at initd.org
Wed Oct 19 10:06:40 CEST 2011

On 19/10/11 09:59, M.-A. Lemburg wrote:
>> risks to become a problem, with the close() that may raise an error
>> > because the connection has been implicitly closed by a communication
>> > error. Note that close() in itself often is a quite safe operation,
>> > not involving database communication, so it is not expected to fail
>> > and may not be well guarded.
> That last sentence is not quite correct: .close() issues an implicit
> .rollback() and usually also tells the database backend to free up
> resources maintained for the connection, so it does require communication
> with the backend.

Here is the problem. Does .close() always issue an implicit .rollback()?
The DBAPI says yes but, as noted previously, the driver can choose to
NOT send a rollback. In fact on the second .close() the driver SHOULD
NOT send a rollback because there is no transaction in progress.

I'd vote for idempotent .close() interpretation too.


Federico Di Gregorio                                       fog at initd.org
              Una nazionale senza neanche una nazione. -- macchinavapore

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/db-sig/attachments/20111019/0275d865/attachment.pgp>

More information about the DB-SIG mailing list