Message345553
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. |
|
Date |
User |
Action |
Args |
2019-06-14 06:08:05 | maggyero | set | recipients:
+ maggyero, bquinlan, pitrou, vstinner, ned.deily, asvetlov, methane, lukasz.langa, serhiy.storchaka |
2019-06-14 06:08:05 | maggyero | set | messageid: <1560492485.93.0.0515191207525.issue37276@roundup.psfhosted.org> |
2019-06-14 06:08:05 | maggyero | link | issue37276 messages |
2019-06-14 06:08:05 | maggyero | create | |
|