diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-07-14 13:26:39 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-07-14 13:26:39 +0200 |
commit | 29597680758e4924aa71fc021465189e153f2016 (patch) | |
tree | f86b35983958ed5d82d8d4c3dd47dd3cd6ca1815 /helpers/lock.py | |
parent | 9b9dd12a0253f2e65c5934068d91b544f7679f12 (diff) | |
download | MusicSampler-29597680758e4924aa71fc021465189e153f2016.tar.gz MusicSampler-29597680758e4924aa71fc021465189e153f2016.tar.zst MusicSampler-29597680758e4924aa71fc021465189e153f2016.zip |
Move from pygame to sounddevice for sound handling
Move lock files to files
Add with statement to lock
Diffstat (limited to 'helpers/lock.py')
-rw-r--r-- | helpers/lock.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/helpers/lock.py b/helpers/lock.py index dff8b1f..85d281a 100644 --- a/helpers/lock.py +++ b/helpers/lock.py | |||
@@ -5,6 +5,12 @@ class Lock: | |||
5 | self.type = lock_type | 5 | self.type = lock_type |
6 | self.lock = threading.RLock() | 6 | self.lock = threading.RLock() |
7 | 7 | ||
8 | def __enter__(self, *args, **kwargs): | ||
9 | self.acquire(*args, **kwargs) | ||
10 | |||
11 | def __exit__(self, type, value, traceback, *args, **kwargs): | ||
12 | self.release(*args, **kwargs) | ||
13 | |||
8 | def acquire(self, *args, **kwargs): | 14 | def acquire(self, *args, **kwargs): |
9 | #print("acquiring lock for {}".format(self.type)) | 15 | #print("acquiring lock for {}".format(self.type)) |
10 | self.lock.acquire(*args, **kwargs) | 16 | self.lock.acquire(*args, **kwargs) |