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 2021-04-04 11:59 by bigbenhur.

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
2021-04-04 11:59:46bigbenhurcreate