]> git.ipfire.org Git - thirdparty/psycopg.git/commit
refactor: don't keep the notifiers backlog handler in the connection state
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 10 Jan 2025 14:17:01 +0000 (15:17 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 13 Jan 2025 20:25:33 +0000 (21:25 +0100)
commit06ae2131b1cca7d0c56f8dfef5d764c3a0b4ca1a
tree02ec0e9678ddb1337737937b3e19fad9b77b5d65
parent0f7005b8ae6896c30664887612ee1313979bf06d
refactor: don't keep the notifiers backlog handler in the connection state

Just keep the queue in the state and special-case its handling in the
`_notify_handler` connection method instead of registering a standard handler.
Set the queue to None to signify that we are in the `notifies()` generator.

This way we don't need the awkward weak-self + class method to avoid a
reference loop and to dereference the connection weak reference another
time, as we just did in `_notify_handler()`. Setting the queue to None
also feels cleaner than adding/removing the handler.

Relates to #975.
psycopg/psycopg/_connection_base.py
psycopg/psycopg/connection.py
psycopg/psycopg/connection_async.py