Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/galaxy/util/sleeper.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 import threading | |
2 | |
3 | |
4 class Sleeper: | |
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() |