Skip to Content
Expert Python Programming - Third Edition
book

Expert Python Programming - Third Edition

by Michał Jaworski, Tarek Ziadé, Cody Jackson
April 2019
Intermediate to advanced
646 pages
16h 48m
English
Packt Publishing
Content preview from Expert Python Programming - Third Edition

Executors and futures

Before we see how to inject threads or processes in to an asynchronous event loop, we will take a closer look at the concurrent.futures module that will later be the main ingredient of our so-called workaround.

The most important classes in the concurrent.futures module are Executor and Future.

Executor represents a pool of resources that may process work items in parallel. This may seem very similar in purpose to classes from the multiprocessing modulePool and dummy.Poolbut it has a completely different interface and semantics. It is a base class not intended for instantiation and has the following two concrete implementations:

  • ThreadPoolExecutor: This is the one that represents a pool of threads
  • ProcessPoolExecutor ...
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

Expert Python Programming - Fourth Edition

Expert Python Programming - Fourth Edition

Michał Jaworski, Tarek Ziade, Tarek Ziadé

Publisher Resources

ISBN: 9781789808896Other