[Python-ideas] async ProcessPoolExecutor

Christoph Groth christoph at grothesque.org
Wed Jun 1 14:47:09 EDT 2016


My first post only hints on how "executor" works.  Here is some more
information:

concurrent.futures.ProcessPoolExecutor uses several queues to keep track
of the pending work.  There's one (potentially long) queue.Queue
instance that holds the work items that have been submitted.  And there
are two (short) queues from multiprocessing that are shared among the
master process and the worker processes: one for dispatching work, and
one for receiving results.  These queues are managed by a routine that
runs in a separate thread of the master process.  Because of the
separate manager thread the Futures from concurrent.futures need to be
thread-safe.

The "executor" package began as a copy of concurrent.features.
Subsequently, I replaced bits by equivalents from asyncio as far as
possible.  This necessitated also some changes to how it works, but the
interface remained mostly unchanged.  The specific changes are most
clearly visible by diffing against process.py from concurrent.futures.

The resulting package is free of locks and threads, except as used
internally by the multiprocessing.Queue instances.



More information about the Python-ideas mailing list