[Zodb-checkins] CVS: ZODB3/ZEO/zrpc - trigger.py:1.6

Guido van Rossum guido@python.org
Sun, 15 Sep 2002 22:39:28 -0400


Update of /cvs-repository/ZODB3/ZEO/zrpc
In directory cvs.zope.org:/tmp/cvs-serv21137

Modified Files:
	trigger.py 
Log Message:
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.


=== ZODB3/ZEO/zrpc/trigger.py 1.5 => 1.6 ===
--- ZODB3/ZEO/zrpc/trigger.py:1.5	Tue Sep 10 17:38:47 2002
+++ ZODB3/ZEO/zrpc/trigger.py	Sun Sep 15 22:39:27 2002
@@ -87,8 +87,8 @@
 
         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 @@
 
         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 @@
 
         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 @@
 
         def handle_read(self):
             self.recv(8192)
+            self.lock.acquire()
             try:
-                self.lock.acquire()
                 for thunk in self.thunks:
                     try:
                         thunk()