✨ NEW: Expose aio_pika.Connection.add_close_callback
#104
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allow
RmqThreadCommunicator
to be initialisedwith a connection_close_callback.
This is an initial step towards addressing aiidateam/aiida-core#4595 (comment).
Note the
aio_pika.RobustConnection
class also has anadd_reconnect_callback
method, but this is not necessary to add if we only want to identify closures (a reconnection is triggered after theclose_callbacks
have been called).Note also that when these callbacks are called, all exceptions are caught (see https://github.com/mosquito/aio-pika/blob/94066fa900d9c08624d936f9b94037640267ac37/aio_pika/tools.py#L162-L168) which may provide some challenges if the goal is to except the daemon worker 😒
Oh and one last thing, the callback can be added as "weak=True" (i.e. to a
WeakSet
) which I'm not sure whether is good to use or not (or to add an additional parameter to control it)