src/eric7/EricUtilities/EricMutexLocker.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9653
e67609152c5e
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
12 12
13 class EricMutexLocker(contextlib.AbstractContextManager): 13 class EricMutexLocker(contextlib.AbstractContextManager):
14 """ 14 """
15 Class implementing a context manager locking and unlocking a mutex. 15 Class implementing a context manager locking and unlocking a mutex.
16 """ 16 """
17
17 def __init__(self, mutex): 18 def __init__(self, mutex):
18 """ 19 """
19 Constructor 20 Constructor
20 21
21 @param mutex reference to the mutex to be locked 22 @param mutex reference to the mutex to be locked
22 @type QMutex or QRecursiveMutex 23 @type QMutex or QRecursiveMutex
23 """ 24 """
24 self.__mutex = mutex 25 self.__mutex = mutex
25 26
26 def __enter__(self): 27 def __enter__(self):
27 """ 28 """
28 Special method called when entering the runtime ccontext. 29 Special method called when entering the runtime ccontext.
29 30
30 @return reference to the context manager object 31 @return reference to the context manager object
31 @rtype EricOverrideCursor 32 @rtype EricOverrideCursor
32 """ 33 """
33 self.__mutex.lock() 34 self.__mutex.lock()
34 35
35 return self 36 return self
36 37
37 def __exit__(self, exc_type, exc_value, traceback): 38 def __exit__(self, exc_type, exc_value, traceback):
38 """ 39 """
39 Special method called when exiting the runtime ccontext. 40 Special method called when exiting the runtime ccontext.
40 41
41 @param exc_type type of an exception raised in the runtime context 42 @param exc_type type of an exception raised in the runtime context
42 @param exc_value value of an exception raised in the runtime context 43 @param exc_value value of an exception raised in the runtime context
43 @param traceback traceback of an exception raised in the runtime 44 @param traceback traceback of an exception raised in the runtime
44 context 45 context
45 @return always returns None to not suppress any exception 46 @return always returns None to not suppress any exception
46 @rtype None 47 @rtype None
47 """ 48 """
48 self.__mutex.unlock() 49 self.__mutex.unlock()
49 50
50 return None # __IGNORE_WARNING_M831__ 51 return None # __IGNORE_WARNING_M831__

eric ide

mercurial