Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/galaxy/util/sleeper.py @ 2:6af9afd405e9 draft
"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
author | shellac |
---|---|
date | Thu, 14 May 2020 14:56:58 -0400 |
parents | 26e78fe6e8c4 |
children |
comparison
equal
deleted
inserted
replaced
1:75ca89e9b81c | 2:6af9afd405e9 |
---|---|
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() |