-
-
Notifications
You must be signed in to change notification settings - Fork 213
Closed
Description
Currently, if Ctrl-C is pressed during a long query, the connection is left in a broken state.
>>> import psycopg
>>> cnn = psycopg.connect()
>>> cnn.execute("select pg_sleep(5)")
^CTraceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/piro/dev/psycopg3/psycopg/psycopg/connection.py", line 808, in execute
return cur.execute(query, params, prepare=prepare)
File "/home/piro/dev/psycopg3/psycopg/psycopg/cursor.py", line 557, in execute
self._conn.wait(
File "/home/piro/dev/psycopg3/psycopg/psycopg/connection.py", line 860, in wait
return waiting.wait(gen, self.pgconn.socket, timeout=timeout)
File "/home/piro/dev/psycopg3/psycopg/psycopg/waiting.py", line 229, in wait_epoll
fileevs = epoll.poll(timeout)
KeyboardInterrupt
>>> cnn.execute("select 1")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/piro/dev/psycopg3/psycopg/psycopg/connection.py", line 811, in execute
raise ex.with_traceback(None)
psycopg.OperationalError: sending query failed: another command is already in progressWhat pgcli does with psycopg2 makes sense: send a cancel and wait for the response. We should probably do the same by default in our wait functions, or maybe just out of them, because inside them we don't really have access to the PGconn structure.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels