Description
In this stackoverflow question, someone gets very confused because they're using time.sleep
and never using await
, so one of their tasks seems to run correctly but the other doesn't. There's no indication of what's going on. Easy to fix once you know how, but if you don't, then how are you supposed to figure it out?
We could, pretty cheaply, add a watchdog to catch such situations. What I'm imagining is that when entering trio.run
, we'd spawn a system task that spins up a thread and watches for the main loop to become stuck. In the main run loop, we'd send it messages occasionally, whenever we (a) start processing a batch of tasks, (b) stop processing a bunch of tasks. If the watchdog thread detects that the time between (a) and (b) exceeds, say, 5 seconds, then it should print an informative message and use the faulthandler
module to dump everyone's stack traces. I think this might be cheap enough it could be enabled-by-default.