We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Advanced asyncio: Solving Real-world Production Problems

Formale Metadaten

Titel
Advanced asyncio: Solving Real-world Production Problems
Serientitel
Anzahl der Teile
118
Autor
Lizenz
CC-Namensnennung - keine kommerzielle Nutzung - Weitergabe unter gleichen Bedingungen 3.0 Unported:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen und nicht-kommerziellen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen und das Werk bzw. diesen Inhalt auch in veränderter Form nur unter den Bedingungen dieser Lizenz weitergeben
Identifikatoren
Herausgeber
Erscheinungsjahr2019
SpracheEnglisch

Inhaltliche Metadaten

Fachgebiet
Genre
Abstract
By building a simplified chaos monkey service, we will walk through how to create a good foundation for an asyncio-based service, including graceful shutdowns, proper exception handling, and testing asynchronous code. We’ll get into the hairier topics as well, covering topics like working with synchronous code, debugging and profiling, and working with threaded code. We’ll learn how to approach asynchronous and concurrent programming with Python’s asyncio library, take away some best practices, and learn what pitfalls to avoid. Outline: (40 minutes + 5 min Q&A, if unable to get 45 minutes, then 30 min slot with no time for Q&A) Intro (2m) Speaker/company intro Setting the context/purpose of talk Foundations (9m - trimmed to 6m for 30 min slot) Initial setup of an asyncio service (2m) --- Required boilerplate code --- Inspiration from official asyncio tutorial docs Making a service emactually/em concurrent (5m) --- non-blocking vs concurrent --- when to be concurrent vs serial --- using callbacks vs awaits vs scheduling tasks (create_task) vs asyncio.Events --- Making synchronous code asyncio-friendly (2m) Intermediate (9m - trimmed to 6m for 30 min slot) Graceful shutdowns (3m) --- What a signal handler is, why it’s needed --- What signals to listen to --- Gotchas of cancelling tasks, asyncio.shield + shutdown behavior Exception handling (3m) --- Difference between top-level exception handling and handling within other coroutines --- Avoid mistakenly swallowing/missing raised exceptions --- Making use of loop.setemexception/emhandler Making threaded code asyncio-“friendly” (3m) --- Calling threaded code from coroutines (aka running within a ThreadPoolExecutor) --- Calling coroutines from from threaded code (aka runemcoroutine/emthreadsafe) Advanced (19m - trimmed to 15m for 30 min slot) Testing asyncio code (7m) --- Benefits of debug mode --- How to mock coroutines Debugging an asyncio service (5m) --- Reinforce debug mode --- Using “tricks"" like codeasyncio.all_tasks/code with logging, codeloop.slow_callback_duration/code, adding context/stack trace in default exception handler Profiling (7m) --- Basic profiling (cProfile, strace) - not that different from sync code --- Continuous profiling with 3rd party tools, i.e. github.com/what-studio/profiling --- PyCharm’s asyncio & thread profiler --- How to properly trace a workflow/request (e.g. for the purpose of distributed tracing) (to be cut if not enough time) Wrap up/Review (1m) /ol
Schlagwörter