stomp.py icon indicating copy to clipboard operation
stomp.py copied to clipboard

Receiver/Heartbeat threads exclusive

Open the01 opened this issue 4 years ago • 2 comments

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?

the01 avatar Dec 10 '20 16:12 the01

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.

kannanF9T avatar Jan 20 '21 13:01 kannanF9T

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

the01 avatar Jan 21 '21 13:01 the01