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':
def pull_trigger(self, thunk=None):
if thunk:
self.lock.acquire()
try:
self.lock.acquire()
self.thunks.append(thunk)
finally:
self.lock.release()
......@@ -96,8 +96,8 @@ if os.name == 'posix':
def handle_read(self):
self.recv(8192)
self.lock.acquire()
try:
self.lock.acquire()
for thunk in self.thunks:
try:
thunk()
......@@ -170,8 +170,8 @@ else:
def pull_trigger(self, thunk=None):
if thunk:
self.lock.acquire()
try:
self.lock.acquire()
self.thunks.append(thunk)
finally:
self.lock.release()
......@@ -179,8 +179,8 @@ else:
def handle_read(self):
self.recv(8192)
self.lock.acquire()
try:
self.lock.acquire()
for thunk in self.thunks:
try:
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