]> git.ipfire.org Git - thirdparty/psycopg.git/commit
refactor: don't keep the notifiers backlog handler in the connection state 992/head
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 10 Jan 2025 14:17:01 +0000 (15:17 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 10 Jan 2025 20:36:47 +0000 (21:36 +0100)
commitffb6171b181330e49f7253d1d2bb78e6e30a7baa
tree532f43b7448ba9c4c94d126c120ac4b36bfaff10
parentaf479e8d66f75c897a5c78b5d28adaa4e5b085b8
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