Commit a702ae71 authored by Guido van Rossum's avatar Guido van Rossum

Change the idiom:

    try:
        self.lock.acquire()
        ...
    finally:
        self.lock.release()

into:

    self.lock.acquire()
    try:
        ...
    finally:
        self.lock.release()

The old version would mistakenly try to release the lock if there was
error in acquiring it.
parent 207efabe
...@@ -87,8 +87,8 @@ if os.name == 'posix': ...@@ -87,8 +87,8 @@ if os.name == 'posix':
def pull_trigger(self, thunk=None): def pull_trigger(self, thunk=None):
if thunk: if thunk:
self.lock.acquire()
try: try:
self.lock.acquire()
self.thunks.append(thunk) self.thunks.append(thunk)
finally: finally:
self.lock.release() self.lock.release()
...@@ -96,8 +96,8 @@ if os.name == 'posix': ...@@ -96,8 +96,8 @@ if os.name == 'posix':
def handle_read(self): def handle_read(self):
self.recv(8192) self.recv(8192)
self.lock.acquire()
try: try:
self.lock.acquire()
for thunk in self.thunks: for thunk in self.thunks:
try: try:
thunk() thunk()
...@@ -170,8 +170,8 @@ else: ...@@ -170,8 +170,8 @@ else:
def pull_trigger(self, thunk=None): def pull_trigger(self, thunk=None):
if thunk: if thunk:
self.lock.acquire()
try: try:
self.lock.acquire()
self.thunks.append(thunk) self.thunks.append(thunk)
finally: finally:
self.lock.release() self.lock.release()
...@@ -179,8 +179,8 @@ else: ...@@ -179,8 +179,8 @@ else:
def handle_read(self): def handle_read(self):
self.recv(8192) self.recv(8192)
self.lock.acquire()
try: try:
self.lock.acquire()
for thunk in self.thunks: for thunk in self.thunks:
try: try:
thunk() thunk()
......
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