New submission from Géry <[email protected]>:
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 <[email protected]>
<https://bugs.python.org/issue37276>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com