[Zodb-checkins] CVS: ZODB3/ZEO - ClientStorage.py:1.51

Jeremy Hylton jeremy@zope.com
Fri, 16 Aug 2002 18:55:45 -0400


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

Modified Files:
	ClientStorage.py 
Log Message:
Add end_transaction() method.

Use this method to set self._transaction to None and notify another
thread.


=== ZODB3/ZEO/ClientStorage.py 1.50 => 1.51 ===
--- ZODB3/ZEO/ClientStorage.py:1.50	Fri Aug 16 18:49:40 2002
+++ ZODB3/ZEO/ClientStorage.py	Fri Aug 16 18:55:44 2002
@@ -351,16 +351,21 @@
         except:
             # Client may have disconnected during the tpc_begin().
             if self._server is not disconnected_stub:
-                self.tpc_cond.acquire()
-                self._transaction = None
-                self.tpc_cond.notify()
-                self.tpc_cond.release()
+                self.end_transaction()
             raise
 
         self._serial = id
         self._seriald.clear()
         del self._serials[:]
 
+    def end_transaction(self):
+        # the right way to set self._transaction to None
+        # calls notify() on tpc_cond in case there are waiting threads
+        self.tpc_cond.acquire()
+        self._transaction = None
+        self.tpc_cond.notify()
+        self.tpc_cond.release()
+
     def tpc_abort(self, transaction):
         if transaction is not self._transaction:
             return
@@ -370,10 +375,7 @@
             self._seriald.clear()
             del self._serials[:]
         finally:
-            self.tpc_cond.acquire()
-            self._transaction = None
-            self.tpc_cond.notify()
-            self.tpc_cond.release()
+            self.end_transaction()
 
     def tpc_finish(self, transaction, f=None):
         if transaction is not self._transaction:
@@ -389,10 +391,7 @@
 
             self._update_cache()
         finally:
-            self.tpc_cond.acquire()
-            self._transaction = None
-            self.tpc_cond.notify()
-            self.tpc_cond.release()
+            self.end_transaction()
 
     def _update_cache(self):
         # Iterate over the objects in the transaction buffer and