Skip to Content
Modern Python Standard Library Cookbook
book

Modern Python Standard Library Cookbook

by Alessandro Molina
August 2018
Intermediate to advanced
366 pages
10h 14m
English
Packt Publishing
Content preview from Modern Python Standard Library Cookbook

Coroutines

Threads are the most common way to implement concurrency in most languages and use cases, but they are expensive in terms of cost, and while ThreadPool can be a good solution for cases when thousands of threads are involved, it's usually unreasonable to involve thousands of threads. Especially when long-lived I/O is involved, you might easily reach thousands of operations running concurrently (think of the amount of concurrent HTTP requests an HTTP server might have to handle) and most of those tasks will be sitting doing nothing, just waiting for data from the network or from the disk most of the time.

In those cases, asynchronous I/O is the preferred approach. Compared to synchronous blocking I/O where your code is sitting there ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Advanced Python Development: Using Powerful Language Features in Real-World Applications

Advanced Python Development: Using Powerful Language Features in Real-World Applications

Matthew Wilkes

Publisher Resources

ISBN: 9781788830829Supplemental Content