From here I have this little example programme.
The problem seems to be list(results). If I do the following in Idle, list(results) will cause Idle to hang, but the programme works fine in bash.
In Idle:
import concurrent.futures
def worker(task):
result = task * 2
print(f"Task {task}: Result = {result}n")
return result
tasks = [1, 2, 3, 4, 5]
results = concurrent.futures.ProcessPoolExecutor().map(worker, tasks)
results
<generator object _chain_from_iterable_of_lists at 0x76ef7d02eb20>
l = list(results)
In Idle this then hangs, nothing happens and ctrl c will not stop it. Only shell restart gets me back.
Here is the little example programme, which works fine in bash:
#! /usr/bin/python3
import concurrent.futures
def worker(task):
result = task * 2
print(f"Task {task}: Result = {result}n")
return result
if __name__ == "__main__":
tasks = [1, 2, 3, 4, 5]
# will not work in the Idle shell
with concurrent.futures.ProcessPoolExecutor() as executor:
results = executor.map(worker, tasks)
# results <generator object _chain_from_iterable_of_lists at 0x76ef7d02eb20>
# list(results) does not work in Idle, but in bash
print("Results:", list(results))