diff options
author | Jonathan Abrahams <jonathan@mongodb.com> | 2016-01-19 15:57:48 -0500 |
---|---|---|
committer | Jonathan Abrahams <jonathan@mongodb.com> | 2016-01-19 15:59:50 -0500 |
commit | 04a340e44af0fdf7e0a66f347a06adf0b56f7e68 (patch) | |
tree | 7921f2f561d27c9975d1871ea62a77535a788c8b | |
parent | c6a984212348346b8c11e1d5d73f1dd52269014d (diff) | |
download | mongo-04a340e44af0fdf7e0a66f347a06adf0b56f7e68.tar.gz |
SERVER-22165 Fix resmoke.py deadlock between logger pipe and timer thread
(cherry picked from commit 8aa1202a37900752c102ce7b324f41853ec5c4c9)
-rw-r--r-- | buildscripts/resmokelib/utils/timer.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/buildscripts/resmokelib/utils/timer.py b/buildscripts/resmokelib/utils/timer.py index 10b788d587f..80531d5db5c 100644 --- a/buildscripts/resmokelib/utils/timer.py +++ b/buildscripts/resmokelib/utils/timer.py @@ -86,14 +86,17 @@ class AlarmClock(threading.Thread): Repeatedly calls 'func' with a delay of 'interval' seconds between executions. If the timer is snoozed before 'func' is called, then it waits to be reset. - After is has been reset, the timer will again wait 'interval' seconds and + After it has been reset, the timer will again wait 'interval' seconds and then try to call 'func'. If the timer is dismissed, then no subsequent executions of 'func' are made. """ - with self.lock: - while not self.dismissed: + while True: + with self.lock: + if self.dismissed: + return + # Wait for the specified amount of time. self.cond.wait(self.interval) @@ -112,8 +115,11 @@ class AlarmClock(threading.Thread): self.snoozed = False continue - # Execute the function. - self.func(*self.args, **self.kwargs) + # Execute the function after the lock has been released to prevent potential deadlocks + # with the invoked function. + self.func(*self.args, **self.kwargs) + # Reacquire the lock. + with self.lock: # Ignore snoozes that took place while the function was being executed. self.snoozed = False |