~/talk

Advanced asyncio: Solving Real-World Production Problems

Talkat PyColorado 2019 · 2019-09-07..09-08· [python]
slides:none on file

Builds a Chaos Monkey–style service called Mayhem Mandrill and shows concrete code patterns that actually work: using asyncio.create_task and asyncio.gather to fan out work, attaching loop signal handlers for graceful shutdown with task cancellation and metric flush, adding a global exception handler and per-task exception handling, using run_coroutine_threadsafe for thread safety, testing with pytest-asyncio and coroutine mocks, and profiling with cProfile pyprof2calltree and kcachegrind to find slow callbacks.

AI-written summary · about

  1. 0:00Start
  2. 4:41building mayhem mandrill
  3. 9:28unblocking: finalization tasks
  4. 11:18initial concurrency setup: tl;dr
  5. 12:43responding to signals
  6. 13:52signal handler
  7. 18:22exception handling
  8. 20:46threads and asyncio
  9. 21:33simple testing with pytest
  10. 22:40mocking coroutines
  11. 24:55testing create task
  12. 26:53testing the event loop
  13. 27:18manual debugging
  14. 27:47using debug mode: traceback context
  15. 28:22using debug mode: thread safety
  16. 28:40using debug mode: slow coros
  17. 29:50debugging asyncio code
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.