New submission from fireattack <[email protected]>:
Example
```
from concurrent.futures import ThreadPoolExecutor
from time import sleep
def wait_on_future():
sleep(1)
print(f.done()) # f is not done obviously
f2 = executor.submit(pow, 5, 2)
print(f2.result())
sleep(1)
executor = ThreadPoolExecutor(max_workers=100)
f = executor.submit(wait_on_future)
executor.shutdown(wait=True)
```
When debugging, it shows "cannot schedule new futures after shutdown":
Exception has occurred: RuntimeError
cannot schedule new futures after shutdown
File "test2.py", line 7, in wait_on_future
f2 = executor.submit(pow, 5, 2)
According to https://docs.python.org/3/library/concurrent.futures.html,
`shutdown(wait=True)` "[s]ignal the executor that it should free any resources
that it is using when the currently pending futures are done executing". But
when f2 is being submitted, f is not done yet, so executor shouldn't be shut
down.
----------
components: Library (Lib)
messages: 365194
nosy: fireattack
priority: normal
severity: normal
status: open
title: ThreadPoolExecutor with wait=True shuts down too early
versions: Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue40093>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com