This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: futures cancelled by ThreadPoolExecutor.shutdown() not yielded by as_completed()
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: bigbenhur
Priority: normal Keywords:

Created on 2021-04-04 11:59 by bigbenhur, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg390183 - (view) Author: bbh (bigbenhur) Date: 2021-04-04 11:59
concurrent.futures.ThreadPoolExecutor.shutdown(cancel_futures=True) cancels the pending futures, but the futures remain in the state CANCELLED and never get to the state CANCELLED_AND_NOTIFIED. Thus they are never yielded by concurrent.futures.as_completed().

If I use shutdown(cancel_futures=True) in a loop of as_completed(), the loop will never finish and the program hangs. Not even Ctrl-C works.

If I use concurrent.futures.Future.cancel() on all pending futures in the loop, everything works as expected.
History
Date User Action Args
2022-04-11 14:59:43adminsetgithub: 87893
2021-04-04 11:59:46bigbenhurcreate