-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for coroutine functions as listener callbacks #802
Conversation
Hi, I've also been working on this! Much less than you though, you've done a lot! I've got a couple of questions, not necessarily criticisms just looking for clarification (I'm fairly new to async).
|
Because
To avoid calling |
My mistake, I incorrectly thought that create_task could be used on both. |
Does this suggestion offer an improvement to your exception handling, or is there no impact? for cb in self._listeners[channel]:
self._loop.create_task(self._call_listener(cb, ...)
async def _call_listener(cb, ...)
try:
if cb.is_async:
await cb.cb(con_ref, pid, channel, payload)
else:
cb.cb(con_ref, pid, channel, payload)
except:
.... |
The event loop already logs exceptions in tasks and callbacks fairly well, and, if anything, I think custom invocation of |
The `Connection.add_listener()`, `Connection.add_log_listener()` and `Connection.add_termination_listener()` now allow coroutine functions as callbacks. Fixes: #567.
25a45fa
to
81cdff9
Compare
Oh nice, that's so much tidier. |
Changes ------- * Drop support for Python 3.5 (#777) (by @and-semakin in da58cd2 for #777) * Add support for Python 3.10 (#795) (by @elprans in abf5569 for #795) * Add support for asynchronous iterables to copy_records_to_table() (#713) (by @elprans in 1d33ff6 for #713) * Add support for coroutine functions as listener callbacks (#802) (by @elprans in 41da093 for #802) * Add support for sslcert, sslkey and sslrootcert parameters to DSN (#768) (by @jdobes and @elprans in c674e86 for #768) * Add copy_ wrappers to Pool (#661) (by @elprans in a6b0f28 for #661) * Add issubset and issuperset methods to the Range type (#563) (by @kdorsel in de07d0a for #563) Fixes ----- * Break connection internal circular reference (#774) (by @fantix in d08a9b8 for #774) * Make Server Version Extraction More Flexible (#778) (by @Natrinicle in d076169 for #778)
Changes ------- * Drop support for Python 3.5 (#777) (by @and-semakin in da58cd2 for #777) * Add support for Python 3.10 (#795) (by @elprans in abf5569 for #795) * Add support for asynchronous iterables to copy_records_to_table() (#713) (by @elprans in 1d33ff6 for #713) * Add support for coroutine functions as listener callbacks (#802) (by @elprans in 41da093 for #802) * Add support for sslcert, sslkey and sslrootcert parameters to DSN (#768) (by @jdobes and @elprans in c674e86 for #768) * Add copy_ wrappers to Pool (#661) (by @elprans in a6b0f28 for #661) * Add issubset and issuperset methods to the Range type (#563) (by @kdorsel in de07d0a for #563) Fixes ----- * Break connection internal circular reference (#774) (by @fantix in d08a9b8 for #774) * Make Server Version Extraction More Flexible (#778) (by @Natrinicle in d076169 for #778)
Changes ------- * Drop support for Python 3.5 (#777) (by @and-semakin in da58cd2 for #777) * Add support for Python 3.10 (#795) (by @elprans in abf5569 for #795) * Add support for asynchronous iterables to copy_records_to_table() (#713) (by @elprans in 1d33ff6 for #713) * Add support for coroutine functions as listener callbacks (#802) (by @elprans in 41da093 for #802) * Add support for sslcert, sslkey and sslrootcert parameters to DSN (#768) (by @jdobes and @elprans in c674e86 for #768) * Add copy_ wrappers to Pool (#661) (by @elprans in a6b0f28 for #661) * Add issubset and issuperset methods to the Range type (#563) (by @kdorsel in de07d0a for #563) Fixes ----- * Break connection internal circular reference (#774) (by @fantix in d08a9b8 for #774) * Make Server Version Extraction More Flexible (#778) (by @Natrinicle in d076169 for #778)
The
Connection.add_listener()
,Connection.add_log_listener()
andConnection.add_termination_listener()
now allow coroutine functions ascallbacks.
Fixes: #567.