3 ms·
I like using it as well, but I've been bit several times by having runtime exceptions completely swallowed.
by fullstop 5y ago
I like using it as well, but I've been bit several times by having runtime exceptions completely swallowed.
- Too 5y agoLet me guess. Using create_task() without await and assuming it will run to completion in the background to trigger some other event? This is almost always the case of async tasks disappearing into the void. After shooting myself in the foot with this one time to many I have a hard rule to never use create_task. Instead make sure every single task ends up in some kind of gather() or wait() awaited from the top level. This will ensure any exceptions are propagated. If the number of tasks are dynamically created, while others are still ongoing, add them to a common list and restart your wait() call.
- fullstop 5y agoYes, exactly this scenario.
- Too 5y ago:) Its not that strange actually. If you compare it to threads, where you shoot off a thread which you never join(). It’s exactly the same scenario. Any thread which doesn’t have a join needs a watchdog. Or register the unhandled exception handler. Can’t remember if threads do this by default. Asyncio tasks for sure don’t, and they can’t really do it either, since a task in error state could be saved for later use for legitimate reasons. Closest you get is the warning printed to log about tasks that got GCd without ever being awaited, if you enable ASYNCIO_DEBUG=1