Skip to content

Instantly share code, notes, and snippets.

@ubershmekel
Created July 11, 2014 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ubershmekel/7c38943afccc58382e4a to your computer and use it in GitHub Desktop.
Save ubershmekel/7c38943afccc58382e4a to your computer and use it in GitHub Desktop.
Kombu unacked messages were missing when calling .get()
"""
Kombu and Celery were doing something strange were I noticed rabbit had
a large number of unacked messages, but when I hit .get() I got nothing.
This manifested on the client side of things at times where it would work once,
hang the next. And then work again.
"""
# This was the bad code
with kombu.Connection(RABBIT_HOST) as conn:
while True:
master_q = conn.SimpleQueue(MASTER_QUEUE)
print('getting')
msg = master_q.get()
# This was the good code, notice I don't redeclare the q in the loop
with kombu.Connection(RABBIT_HOST) as conn:
master_q = conn.SimpleQueue(MASTER_QUEUE)
while True:
print('getting')
msg = master_q.get()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment