Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix calling cleanup function in Worker.run() to avoid race condition #1455

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions minio/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,18 +829,19 @@ def run(self):
if not task:
self._tasks_queue.task_done()
break

balamurugana marked this conversation as resolved.
Show resolved Hide resolved
func, args, kargs, cleanup_func = task
# No exception detected in any thread,
# continue the execution.
if self._exceptions_queue.empty():
# Execute the task
func, args, kargs, cleanup_func = task
try:
result = func(*args, **kargs)
self._results_queue.put(result)
except Exception as ex: # pylint: disable=broad-except
self._exceptions_queue.put(ex)
finally:
cleanup_func()

# call cleanup i.e. Semaphore.release irrespective of task execution to avoid race condition.
balamurugana marked this conversation as resolved.
Show resolved Hide resolved
cleanup_func()
detailyang marked this conversation as resolved.
Show resolved Hide resolved
# Mark this task as done, whether an exception happened or not
self._tasks_queue.task_done()

Expand Down