Hi Pika,
I have read some post in this group and I don’t understand what is the point of using:
https://github.com/pika/pika/blob/main/examples/basic_consumer_threaded.py
I mean, why we need one additional thread for processing message and calling add_callback_threadsafe where as argument we pass ack method (both activities in the same new thread for processing).
I wonder how we prevent form closing connection from channel with we consume message, because if processing is longer than heartbeat value we send ack afterwards and it is for me the same case like just consuming in the main thread and then sending ack.
What is the difference if we run processing and sending ack in separate one thread?
I am new in python and pika so sorry if this question is strange
My code is production and proprietary and I can't share it.
I receive a message from the channel and process it. However, sometimes when making a request to Azure, I may get a very delayed response. I'm wondering how not to end the connection, I have heartbeat set to 300s and from the documentation I know that the server will send heartbeats every hertbeat/2 = 150s. However, if I process the message for more than 300s, the connection is closed and I can't send the ack. Everything happens at the main thread level. Would separating this, like in your github example, into a separate thread help?
if so, why, I can't understand what gives us processing in a new thread and sending the ack in the same thread. For me the only difference is that we do it in a new thread instead of the main thread. Please advise
1. Will a blocking HTTP request using azure client in a new thread would block I/O loop? (blocking request is in the new processing thread. Will it block the i/o loop)?
2. How to create only one additional thread all the time, and not consume a lot of memory, I mean that callback will be triggered after sending ack(right?). Later in your example callback adds new threads all the time, I can't join that threads because it will block I/O loop. Will an executor with size = 1 be ok? Thread after ack has already finished its work, so it seems sensible.