Streaming templates with asyncio
summary
Converts a whitespace-y templating engine to stream HTML by having render return an AsyncIO queue so fragments are streamed incrementally to the client; uses AsyncIO queues and generator coroutines with yield from not yield to compose I/O and delegate parsing; finds AsyncIO overhead small versus generator work but generator-context switching is costly; discovers a running-renderer death can leave sockets open and needs task supervision and timeouts; pdb debugging works.
AI-written summary · about
chapters (13)
- 0:00Intro
- 1:44What is this talk about
- 3:26Wither Example
- 4:22Wither 3
- 6:37Implementation
- 8:09Performance
- 10:45What I learned
- 14:53Things to avoid
- 16:25Good parts
- 19:41Bad Parts
- 23:59Stack Traces
- 24:29What is here already
- 25:50What is missing
related talks
01h 26mBeyond Python Enhanced Generators
26mUsing Django 4.2's StreamingHttpResponse and HTMX SSE to provide real time notifications
24mA Crash Course in Python 3's asyncio
59mGet to grips with asyncio in Python 3
56mLeveraging Async and Await in Modern Python
30mLet's get you started with asynchronous programming
32mDemystifying AsyncIO: Building Your Own Event Loop in Python
01h 00mCoroutine Concurrency in Python 3 with asyncio
