comparison planemo/lib/python3.7/site-packages/galaxy/util/sleeper.py @ 1:56ad4e20f292 draft

"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author guerler
date Fri, 31 Jul 2020 00:32:28 -0400
parents
children
comparison
equal deleted inserted replaced
0:d30785e31577 1:56ad4e20f292
1 import threading
2
3
4 class Sleeper(object):
5 """
6 Provides a 'sleep' method that sleeps for a number of seconds *unless*
7 the notify method is called (from a different thread).
8 """
9
10 def __init__(self):
11 self.condition = threading.Condition()
12
13 def sleep(self, seconds):
14 # Should this be in a try/finally block? -John
15 self.condition.acquire()
16 self.condition.wait(seconds)
17 self.condition.release()
18
19 def wake(self):
20 # Should this be in a try/finally block? -John
21 self.condition.acquire()
22 self.condition.notify()
23 self.condition.release()