If an asyncio Task fails in the woods and nobody is around to see it, does i....
summary
Production asyncio code at a large site with hundreds of backend services yields concrete mistakes: asyncio.run is the right bootstrap, nested event loops (you paused the caller’s loop and made a new one) causes expired timeouts and strange tracebacks, and anonymous tasks silently print exceptions until a 3am pager. Use async context managers, exit stacks or a nursery/watcher (the later package) to manage lifetimes, obey cancellation (re-raise CancelledError after cleanup), and add timeouts around awaited operations.
AI-written summary · about
chapters (16)
- 0:00Start
- 2:16You want to use some asyncio from an existing blocking function.
- 6:53What is bootstrapping
- 7:12It is important to have clean async bootstrapping
- 8:55Set it and forget it
- 9:48Solution: The nursery from trio
- 11:14Terrible Tradeoffs
- 12:33calling coroutines from a class _init_
- 14:26The better pattern
- 15:08You need signal handling
- 15:23Terrible Signal Handling Example
- 18:39How does Cancellation work?
- 19:42Cancellation is a Contract
- 23:42You need to use timeouts.
- 23:57chance an asyne call doesn't complete
- 27:36Questions?
related talks
40mAdvanced asyncio: Solving Real-world Production Problems
32mAdvanced asyncio: Solving Real-World Production Problems
19mUnblocking the Loop: Mastering Python's I/O Loop Monitoring
32mEnhancing AsyncIO for Complex Applications
23mPractical usage of asyncio
59mGet to grips with asyncio in Python 3
50mUsing Asyncio in Python 3
25mZoom, Enhance: Asyncio's New Introspection Powers
