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):
829829 if not task :
830830 self ._tasks_queue .task_done ()
831831 break
832+ func , args , kargs , cleanup_func = task
832833 # No exception detected in any thread,
833834 # continue the execution.
834835 if self ._exceptions_queue .empty ():
835- # Execute the task
836- func , args , kargs , cleanup_func = task
837836 try :
838837 result = func (* args , ** kargs )
839838 self ._results_queue .put (result )
840839 except Exception as ex : # pylint: disable=broad-except
841840 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 ()
844845 # Mark this task as done, whether an exception happened or not
845846 self ._tasks_queue .task_done ()
846847
You can’t perform that action at this time.
0 commit comments