]> git.ipfire.org Git - thirdparty/psycopg.git/commit
Implement connection/cursor procedures as generators
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 22 Dec 2020 17:09:34 +0000 (18:09 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 24 Dec 2020 03:51:34 +0000 (04:51 +0100)
commit151465ff301d985fb1c40feabd8e9d15e31c800c
treeb9c9b02b74351c6a91d8cfcc123f307e75549e43
parent6f0b6db6f95bcad4be47ecea99732c3f17073e7d
Implement connection/cursor procedures as generators

Generators are common to both sync and async code so there is much less
code duplication, which will be useful in the light of doing more
complex things such as prepared transactions.

As a side effect of the refactoring, operations on closed connections
are raised as OperationalError rather than InterfaceError because
connection closure may depend on external factors.

Dropped fd from PQGen stream: the having the fd in the middle of the
`Ready` values made more difficult to chain more than one operation in
the same generator. The fd is not passed as extra parameter.
13 files changed:
psycopg3/psycopg3/connection.py
psycopg3/psycopg3/cursor.py
psycopg3/psycopg3/generators.py
psycopg3/psycopg3/proto.py
psycopg3/psycopg3/transaction.py
psycopg3/psycopg3/waiting.py
psycopg3_c/psycopg3_c/generators.pyx
tests/pq/test_async.py
tests/pq/test_pgconn.py
tests/test_connection.py
tests/test_connection_async.py
tests/test_transaction.py
tests/test_transaction_async.py