Kaydet (Commit) c951bf91 authored tarafından Tim Peters's avatar Tim Peters

SF bug [#410708] Condition.wait() and KeyboardInterrupt.

http://sourceforge.net/tracker/?func=detail&aid=410708&group_id=5470&atid=105470
Added try/finally around Condition.wait() guts, so that the lock state gets
restored at the end no matter what happens.
üst f5bd6843
...@@ -185,6 +185,7 @@ class _Condition(_Verbose): ...@@ -185,6 +185,7 @@ class _Condition(_Verbose):
waiter.acquire() waiter.acquire()
self.__waiters.append(waiter) self.__waiters.append(waiter)
saved_state = self._release_save() saved_state = self._release_save()
try: # restore state no matter what (e.g., KeyboardInterrupt)
if timeout is None: if timeout is None:
waiter.acquire() waiter.acquire()
if __debug__: if __debug__:
...@@ -209,6 +210,7 @@ class _Condition(_Verbose): ...@@ -209,6 +210,7 @@ class _Condition(_Verbose):
else: else:
if __debug__: if __debug__:
self._note("%s.wait(%s): got it", self, timeout) self._note("%s.wait(%s): got it", self, timeout)
finally:
self._acquire_restore(saved_state) self._acquire_restore(saved_state)
def notify(self, n=1): def notify(self, n=1):
......
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