Skip to content

using add_callback_threadsafe lost acknowledgement when stopping program #1402

Answered by lukebakken
Stephane-Thales asked this question in Q&A
Discussion options

You must be logged in to vote

@Stephane-Thales please see the latest version of my code here:

https://github.com/lukebakken/pika-1402/blob/lukebakken/pika-1402/test_pika_blockthread.py

Note that I did the following

  • Simplified it a bit by removing the "batch processing via Queue" code since it wasn't related to the current issue
  • Moved the Pika connection to its own thread
  • Instead of using a consume callback, move to a generator-style for loop which allows for checking if exiting is requested. This could also be accomplished via SelectConnection and a timer.

The code works correctly when CTRL-C is pressed. My guess is that the original issue stems from the fact that BlockingConnection is built on top of SelectConnection

Replies: 2 comments 14 replies

Comment options

You must be logged in to vote
4 replies
@lukebakken
Comment options

@Stephane-Thales
Comment options

@lukebakken
Comment options

@Stephane-Thales
Comment options

Comment options

You must be logged in to vote
10 replies
@lukebakken
Comment options

@lukebakken
Comment options

@Stephane-Thales
Comment options

@lukebakken
Comment options

@Stephane-Thales
Comment options

Answer selected by Stephane-Thales
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants