From b78200b42aeec187ee2b025753ff4694a06681a9 Mon Sep 17 00:00:00 2001 From: Ted Singer Date: Fri, 9 Jun 2023 00:25:00 -0400 Subject: [PATCH] announce done if the threadpool itself has an error --- s3transfer/futures.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/s3transfer/futures.py b/s3transfer/futures.py index 39e071fb..fccc997d 100644 --- a/s3transfer/futures.py +++ b/s3transfer/futures.py @@ -320,7 +320,15 @@ def submit(self, executor, task, tag=None): task, executor, self.transfer_id ) ) - future = executor.submit(task, tag=tag) + try: + future = executor.submit(task, tag=tag) + except RuntimeError: + # We just tried to submit a task to an executor that was shutdown + # If that task was the CompleteDownloadNOOPTask, then we had + # expected it to call .announce_done(). If that isn't happening, + # then we need to call it ourselves + self.announce_done() + raise # Add this created future to the list of associated future just # in case it is needed during cleanups. self.add_associated_future(future)