From the description in the pika
documentation, I can't quite get what add_callback_threadsafe()
method does. It says, "Requests a call to the given function as soon as possible in the context of this connection’s thread". Specifically, which event does this callback get associated to? Since, add_callback_threadsafe()
doesn't receive any "event" argument, how does pika
know when to invoke that callback?
Also, in the official example, why do we even need to build the partial function and register the callback in the do_work() method? Could we not just call the ack_message()
method after the time.sleep()
is over?