[issue37276] Incorrect number of running calls in ProcessPoolExecutor

Géry report at bugs.python.org
Fri Jun 14 02:08:05 EDT 2019


New submission from Géry <gery.ogam at gmail.com>:

In the `concurrent.futures` standard module, the number of running calls in a `ProcessPoolExecutor` is `max_workers + 1` (unexpected) instead of `max_workers` (expected) like in a `ThreadingPoolExecutor`.

The following code snippet which submits 8 calls to 2 workers in a `ProcessPoolExecutor`:

    import concurrent.futures
    import time
    
    
    def call():
        while True:
            time.sleep(1)
    
    
    if __name__ == "__main__":
        with concurrent.futures.ProcessPoolExecutor(max_workers=2) as executor:
            futures = [executor.submit(call) for _ in range(8)]
    
            for future in futures:
                print(future.running())

prints this (3 running calls; unexpected since there are 2 workers):

> True
> True
> True
> False
> False
> False
> False
> False

while using a `ThreadPoolExecutor` prints this (2 running calls; expected):

> True
> True
> False
> False
> False
> False
> False
> False

Tested on both Windows 10 and MacOS 10.14.

----------
components: Library (Lib)
messages: 345553
nosy: asvetlov, bquinlan, inada.naoki, lukasz.langa, maggyero, ned.deily, pitrou, serhiy.storchaka, vstinner
priority: normal
severity: normal
status: open
title: Incorrect number of running calls in ProcessPoolExecutor
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37276>
_______________________________________


More information about the Python-bugs-list mailing list