Kaydet (Commit) 21b60147 authored tarafından Guido van Rossum's avatar Guido van Rossum

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.
üst d584368d
...@@ -318,19 +318,25 @@ class _Event(_Verbose): ...@@ -318,19 +318,25 @@ class _Event(_Verbose):
def set(self): def set(self):
self.__cond.acquire() self.__cond.acquire()
try:
self.__flag = True self.__flag = True
self.__cond.notifyAll() self.__cond.notifyAll()
finally:
self.__cond.release() self.__cond.release()
def clear(self): def clear(self):
self.__cond.acquire() self.__cond.acquire()
try:
self.__flag = False self.__flag = False
finally:
self.__cond.release() self.__cond.release()
def wait(self, timeout=None): def wait(self, timeout=None):
self.__cond.acquire() self.__cond.acquire()
try:
if not self.__flag: if not self.__flag:
self.__cond.wait(timeout) self.__cond.wait(timeout)
finally:
self.__cond.release() self.__cond.release()
# Helper to generate new thread names # Helper to generate new thread names
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment