-
Notifications
You must be signed in to change notification settings - Fork 298
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
Fix maintaining pipeline when using AMQP #2533
base: develop
Are you sure you want to change the base?
Conversation
If RabbitMQ droped the connection, pika can emit the StreamLostError which can be gracefully handled by reconnection attempt. In addition, consuming on BlockingConnection without the timeout can block internal maintanence operations, like sending heartbeats [1]. [1] https://pika.readthedocs.io/en/1.2.0/modules/adapters/blocking.html#pika.adapters.blocking_connection.BlockingChannel.consume
dba7533
to
d10439d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't test now if the code changes themselves but they all look reasonable.
if reconnect and ( | ||
isinstance(exc, pika.exceptions.ConnectionClosed) or | ||
isinstance(exc, pika.exceptions.StreamLostError) | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if reconnect and ( | |
isinstance(exc, pika.exceptions.ConnectionClosed) or | |
isinstance(exc, pika.exceptions.StreamLostError) | |
): | |
if reconnect and isinstance(exc, (pika.exceptions.ConnectionClosed, pika.exceptions.StreamLostError)): |
method, _, body = next( | ||
self.channel.consume(self.source_queue, inactivity_timeout=self.heartbeat / 2) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add an inline comment on why there's a need for a loop and why you chose heartbeat/2
? That will make our lives easier when reading the code later on.
@@ -12,6 +12,7 @@ | |||
### Configuration | |||
|
|||
### Core | |||
- Fix maintaining pipeline connection when using AMQP (PR# by Kamil Mankowski). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Fix maintaining pipeline connection when using AMQP (PR# by Kamil Mankowski). | |
- AMQP: Fix maintaining pipeline connection when during interrupted connections (PR#2533 by Kamil Mankowski). |
If RabbitMQ dropped the connection, pika can emit the StreamLostError which can be gracefully handled by reconnection attempt. In addition, consuming on BlockingConnection without the timeout can block internal maintenance operations, like sending heartbeats [1].
[1] https://pika.readthedocs.io/en/1.2.0/modules/adapters/blocking.html#pika.adapters.blocking_connection.BlockingChannel.consume