7. Concurrency-and-Parallelism¶
- 7.1. Use subprocess to Manage Child Processes
- 7.2. Use Threads for Blocking I/O, Avoid for Parallelism
- 7.3. Use Lock to Prevent Data Races in Threads
- 7.4. Use Queue to Coordinate Work Between Threads
- 7.5. Know How to Recognize When Concurrency Is Necessary
- 7.6. Avoid Creating New Thread Instances for On-demand Fan-out
- 7.7. Understand How Using Queue for Concurrency Requires Refactoring
- 7.8. Consider ThreadPoolExecutor When Threads Are Necessary for Concurrency
- 7.9. Achieve Highly Concurrent I/O with Coroutines
- 7.10. Know How to Port Threaded I/O to asyncio
- 7.11. Mix Threads and Coroutines to Ease the Transition to asyncio
- 7.12. Avoid Blocking the asyncio Event Loop to Maximize Responsiveness
- 7.13. Consider concurrent.futures for True Parallelism