-
-
Notifications
You must be signed in to change notification settings - Fork 207
Closed
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
The connection block is more well behaved:
>>> with psycopg.connect() as cnn:
... cnn.execute("select 1")
... cnn.close()
... 1/0
...
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
ZeroDivisionError: division by zeroThe transaction block doesn't check the connection before trying a rollback:
>>> cnn = psycopg.connect()
>>> with cnn.transaction():
... cnn.execute("select 1")
... cnn.close()
... 1/0
...
Traceback (most recent call last):
File "/home/piro/dev/psycopg3/psycopg/psycopg/connection.py", line 744, in transaction
yield tx
File "<stdin>", line 4, in <module>
ZeroDivisionError: division by zero
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
File "/usr/lib/python3.8/contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "/home/piro/dev/psycopg3/psycopg/psycopg/connection.py", line 744, in transaction
yield tx
File "/home/piro/dev/psycopg3/psycopg/psycopg/transaction.py", line 205, in __exit__
return self._conn.wait(self._exit_gen(exc_type, exc_val, exc_tb))
File "/home/piro/dev/psycopg3/psycopg/psycopg/connection.py", line 767, in wait
return waiting.wait(gen, self.pgconn.socket, timeout=timeout)
File "psycopg_c/pq/pgconn.pyx", line 186, in psycopg_c.pq.PGconn.socket.__get__
File "psycopg_c/pq/pgconn.pyx", line 632, in psycopg_c.pq._call_int
File "psycopg_c/pq/pgconn.pyx", line 614, in psycopg_c.pq._ensure_pgconn
psycopg.OperationalError: the connection is closedleaving the transaction block should behave like for the connection.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers