The _Event class should be more careful with releasing its lock when
interrupted. A try/finally will do nicely. Maybe other classes need this too, but since they manipulate more state it's less clear that that is always the right thing, and I'm in a hurry. Backport candidate.
This commit is contained in:
parent
d584368dec
commit
21b60147e9
|
@ -318,20 +318,26 @@ class _Event(_Verbose):
|
||||||
|
|
||||||
def set(self):
|
def set(self):
|
||||||
self.__cond.acquire()
|
self.__cond.acquire()
|
||||||
self.__flag = True
|
try:
|
||||||
self.__cond.notifyAll()
|
self.__flag = True
|
||||||
self.__cond.release()
|
self.__cond.notifyAll()
|
||||||
|
finally:
|
||||||
|
self.__cond.release()
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
self.__cond.acquire()
|
self.__cond.acquire()
|
||||||
self.__flag = False
|
try:
|
||||||
self.__cond.release()
|
self.__flag = False
|
||||||
|
finally:
|
||||||
|
self.__cond.release()
|
||||||
|
|
||||||
def wait(self, timeout=None):
|
def wait(self, timeout=None):
|
||||||
self.__cond.acquire()
|
self.__cond.acquire()
|
||||||
if not self.__flag:
|
try:
|
||||||
self.__cond.wait(timeout)
|
if not self.__flag:
|
||||||
self.__cond.release()
|
self.__cond.wait(timeout)
|
||||||
|
finally:
|
||||||
|
self.__cond.release()
|
||||||
|
|
||||||
# Helper to generate new thread names
|
# Helper to generate new thread names
|
||||||
_counter = 0
|
_counter = 0
|
||||||
|
|
Loading…
Reference in New Issue