stomp.py
stomp.py copied to clipboard
Receiver/Heartbeat threads exclusive
I have noticed a couple times a weird behavior: Given
- that there are several messages in the queue (300 in my case)
- I have a quick on_message function (<0.5 sec); with ack() at the end Then it will first start to process multiple messages, while not sending (logging) any heartbeats. After some time it will switch, only sending heartbeats, but not processing message (with a full queue). I would expect, that both is being done continuously since they are running in separate threads.
Is this some problematic setting on my part, intended behavior, .. . Any suggestions why this happens or how to fix it?
In python at any point of time within a process single thread will get executed. There is a concept called GIL, It's like mutex which will allow only one thread to execute at a time.
True, but from my understanding are heartbeat and rx two different loops in two threads. So when the rx-thread does (network) io work, like socket listen/receive, shouldn't that then execute the heartbeat thread? To a degree this might be related to #340 if it is processing multiple messages in one loop, but not to this degree. Also the fix from that issue did not change the behaviour