]> git.ipfire.org Git - thirdparty/psycopg.git/commit
feat: add encrypted and non-blocking cancellation
authorDenis Laxalde <denis.laxalde@dalibo.com>
Fri, 24 Mar 2023 13:55:18 +0000 (14:55 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 9 Apr 2024 10:07:43 +0000 (12:07 +0200)
commiteb35c81c43aa9912b5193585b3d81a5568430b8b
tree199da8a259eae3ba6498bb034152e973069d8fcc
parentaf98467e7d1c4f257bd664b14dd20c7b5d48cf50
feat: add encrypted and non-blocking cancellation

We introduce Connection.cancel_safe() which uses the encrypted and
non-blocking libpq cancellation API available with PostgreSQL 17. As a
non-blocking entry point, cancel_safe() delegates to a generator function,
namely _cancel_gen(). If the libpq version is too old, the method raises
a NotSupportedError.

CTRL+C handling (in Connection.wait() or Cursor.stream()) also uses the
non-blocking cancellation but falls back to old method if the former is
not supported.

The behavior of cancel() method (either on Connection or
AsyncConnection) is kept unchanged to use the old cancellation API.
12 files changed:
docs/api/connections.rst
docs/news.rst
psycopg/psycopg/_connection_base.py
psycopg/psycopg/connection.py
psycopg/psycopg/connection_async.py
psycopg/psycopg/cursor.py
psycopg/psycopg/cursor_async.py
tests/test_concurrency_async.py
tests/test_connection.py
tests/test_connection_async.py
tests/test_tpc.py
tests/test_tpc_async.py