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

Guido van Rossum guido@python.org
Tue, 17 Sep 2002 13:06:29 -0400


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

Modified Files:
	ClientStorage.py 
Log Message:
new_oid() wouldn't release  _oid_lock if an exception happened (like
the _server.new_oids() raising Disconnected or ReadOnlyError).  Fixed
by adding a try/finally.


=== ZODB3/ZEO/ClientStorage.py 1.59 => 1.60 ===
--- ZODB3/ZEO/ClientStorage.py:1.59	Fri Sep 13 17:08:48 2002
+++ ZODB3/ZEO/ClientStorage.py	Tue Sep 17 13:06:29 2002
@@ -329,12 +329,13 @@
             raise POSException.ReadOnlyError()
         # avoid multiple oid requests to server at the same time
         self._oid_lock.acquire()
-        if not self._oids:
-            self._oids = self._server.new_oids()
-            self._oids.reverse()
-        oid = self._oids.pop()
-        self._oid_lock.release()
-        return oid
+        try:
+            if not self._oids:
+                self._oids = self._server.new_oids()
+                self._oids.reverse()
+            return self._oids.pop()
+        finally:
+            self._oid_lock.release()
 
     def pack(self, t=None, rf=None, wait=0, days=0):
         # XXX Is it okay that read-only connections allow pack()?