diff options
Diffstat (limited to 'helpers/lock.py')
-rw-r--r-- | helpers/lock.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/helpers/lock.py b/helpers/lock.py new file mode 100644 index 0000000..dff8b1f --- /dev/null +++ b/helpers/lock.py | |||
@@ -0,0 +1,15 @@ | |||
1 | import threading | ||
2 | |||
3 | class Lock: | ||
4 | def __init__(self, lock_type): | ||
5 | self.type = lock_type | ||
6 | self.lock = threading.RLock() | ||
7 | |||
8 | def acquire(self, *args, **kwargs): | ||
9 | #print("acquiring lock for {}".format(self.type)) | ||
10 | self.lock.acquire(*args, **kwargs) | ||
11 | |||
12 | def release(self, *args, **kwargs): | ||
13 | #print("releasing lock for {}".format(self.type)) | ||
14 | self.lock.release(*args, **kwargs) | ||
15 | |||