Inconsitent behaviour of BlockingChannel.Consume generator
See original GitHub issueI run the following code with one message in ‘test’ queue:
import pika
connection = pika.BlockingConnection()
channel = connection.channel()
channel.basic_qos(prefetch_count=1)
for method_frame, properties, body in channel.consume('test', inactivity_timeout=0):
# Display the message parts
print method_frame
# Acknowledge the message
channel.basic_nack(method_frame.delivery_tag, requeue=True)
since i’m requeing, i exepct the generator to always return the same message, over and over. in reality, the loop returns a message every 6/7 iterations, and on other times, it returns (None, None, None). It seems like some kind of a race condition, because if i set inactivity_timeout to be a very small non-zero (like 0.01), it works as expected… is this a bug, or am i missing something? (note: this is the only consumer on the queue)
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Inconsistent Blocking Connection hanging when consumer ...
When the connection is left idle for a long time (e.g. 10 hours). A consumer hangs and does not consume anymore messages. ......
Read more >Using the BlockingChannel.consume generator to ... - Pika
The BlockingChannel.consume method is a generator that will return a tuple of method, properties and body. When you escape out of the loop,...
Read more >Synchronous and blocking consumption in RabbitMQ ...
I want to consume a queue (RabbitMQ) synchronously with blocking. Note: below is full code ready to be run. The system set up...
Read more >PLECS - User Manual
any signal generated from one of the control blocks in PLECS. In Fig. 1.5 we used a pulse generator with a period of...
Read more >RFC 3550: RTP: A Transport Protocol for Real-Time ...
The protocol supports the use of RTP-level translators and mixers. ... RTCP serves as a convenient channel to reach all the participants, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In the case when zero is used as
inactivity_timeout
, the entire frame is more likely to not be available immediately, and you are more likely to hit the(None, None, None)
case.inactivity_timeout
exists so that users can do useful work during the consume loop. In any case, the(None, None, None)
return value is normal and should be handled.Thanks!
As I wrote on the original issue, when passing non-zero to inactivity_timeout, no matter how small, it works as I expected… So I looked at the implementation of the generator, and looked for uses of inactivity_timeout. I saw it being passed to process_data_events() as a parameter. I didn’t keep digging, but my gut feeling was that when I pass 0 to process_data_events() It doesn’t actually process the frame of the message being available again, while when I pass a non-zero small number, I does process the frame… Again…i didn’t investigate deeply, just reporting on my results, and my hypothesis…