question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsitent behaviour of BlockingChannel.Consume generator

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lukebakkencommented, Jan 22, 2019

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

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!

0reactions
Avivsalemcommented, Jan 22, 2019

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…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found