-
Notifications
You must be signed in to change notification settings - Fork 840
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
BlockingChannel can't stop_consuming #770
Comments
@antoineleclair, I would never call something from a signal handler that's not explicitly documented as "signal-safe". That's asking for trouble. Also, using the private instance variable The following may work for you, using documented public API:
I am generally not crazy about polling, but Hope this helps! |
Please close the issue if my reply resolved the problem. |
@antoineleclair - And another thing, if there is the possibility that your RabbitMQ server may run low on resources (low disk space, low RAM), then RabbitMQ will go into blocking mode (won't be reading from your connection), which may block your For that, there is a new feature in master branch (not released yet), that allows you to set a blocked connection timeout. Find out more here: pika/pika/adapters/blocking_connection.py Lines 285 to 307 in 7922e07
|
Thanks @vitaly-krugl, that did it. Much cleaner with Also, if my opinion can be useful, I would have expected, from an API design perspective, |
@antoineleclair, thank you for your update and feedback. A pika connection is not thread-safe. Same concerning signal-safety. Supporting those paradigms typically introduces significant complexity and performance issues and is outside the scope of this library. |
In what scope does the callback in
I have the BlockingConnection.add_timeout running as part of a class, and I want to access attributes of that class (something like RpcServer.is_running() ? ). But it seems like the variables do not update in this scope. |
@guysoft - since this issue is closed and the last response from 2016, please open a new issue with a description of what you are trying to accomplish and what you observe. Also, provide a runnable code sample that demonstrates it. That will be the most help to Pika's maintainers, who are all volunteers. Thank you! |
Ok, I fixed my issue (using basic_consume and handling it myself). But basically the issue was this: |
I throw no clear way to solve (pika-stop-consuming-does-not-work) |
like this???
with |
@wanguanfu - please provide code that reproduces your issue and attach it as a new message to the |
When using a
BlockingChannel
to consume many queues withstart_consuming
, there's no way tostop_consuming
cleanly, unless a message is received.If a message is received, then the message "Never reaches hhere unless a message is dequeued" is printed. My best guess is that this line is causing the problem:
pika/pika/adapters/blocking_connection.py
Line 1755 in 51fd186
In the example above, replacing the line
with
seems to fix the issue. However, I'm a bit cautious that this fix will cause other issues due to the fact that the
BlockingConnection
is not thread safe.Also, just to clarify what I'm trying to do here: I want to consume many queues and shutdown gracefully when a SIGTERM signal is received. I want the messages that are currently processing to complete (and ACK) before closing everything. And I also want to exit quick (1 second is acceptable) if there are no messages currently being processed.
The text was updated successfully, but these errors were encountered: