[New-bugs-announce] [issue43727] futures cancelled by ThreadPoolExecutor.shutdown() not yielded by as_completed()
report at bugs.python.org
Sun Apr 4 07:59:46 EDT 2021
New submission from bbh <benj.luethi at gmx.net>:
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.
components: Library (Lib)
title: futures cancelled by ThreadPoolExecutor.shutdown() not yielded by as_completed()
versions: Python 3.9
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce