2 ms·
async def process(): time.sleep(JOB_DURATION) # simulate CPU time This is synchronous (blocking) code, so if that is scheduled all at once that will bl
by erdewit 6y ago
async def process():
time.sleep(JOB_DURATION) # simulate CPU time
This is synchronous (blocking) code, so if that is scheduled all at once that will block the event loop and make the heartbeat late. It's first come first served cooperative concurrency after all.
A better solution is to make the CPU intensive code cooperative by running it in a different thread or process.
> Never, ever use unbounded queues.
Hmm... I rather like them. But the consumers must be able to keep up with the producers or their must be some form of back pressure.