Summary
In this chapter we have navigated through some of the most common implementation errors that can be incurred when you use asynchronous programming with the standard asyncio library. These errors can have a direct impact on the performance of your solutions and serve to remind us that asynchronous programming doesn’t invariably imply better performance instantly. To summarize the practices presented in this chapter:
- Do not mix blocking code inside asynchronous coroutines/tasks
- Avoid waiting for one coroutine or task to finish before launching another
- Favor launching enough tasks concurrently to maximize the usage of the underlying resources
- Do not launch a huge number of small tasks, to avoid incurring unnecessary context switching between them
- Apply consistent management of exceptions inside the coroutines/tasks and proper handling of exceptions in parent threads
- Separate logging tasks from the main execution thread to maximize...