File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -829,18 +829,19 @@ def run(self):
829
829
if not task :
830
830
self ._tasks_queue .task_done ()
831
831
break
832
+ func , args , kargs , cleanup_func = task
832
833
# No exception detected in any thread,
833
834
# continue the execution.
834
835
if self ._exceptions_queue .empty ():
835
- # Execute the task
836
- func , args , kargs , cleanup_func = task
837
836
try :
838
837
result = func (* args , ** kargs )
839
838
self ._results_queue .put (result )
840
839
except Exception as ex : # pylint: disable=broad-except
841
840
self ._exceptions_queue .put (ex )
842
- finally :
843
- cleanup_func ()
841
+
842
+ # call cleanup i.e. Semaphore.release irrespective of task
843
+ # execution to avoid race condition.
844
+ cleanup_func ()
844
845
# Mark this task as done, whether an exception happened or not
845
846
self ._tasks_queue .task_done ()
846
847
You can’t perform that action at this time.
0 commit comments