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

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.
parent ac6b4e7f
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
############################################################################## ##############################################################################
"""Network ZODB storage client """Network ZODB storage client
$Id: ClientStorage.py,v 1.59 2002/09/13 21:08:48 gvanrossum Exp $ $Id: ClientStorage.py,v 1.60 2002/09/17 17:06:29 gvanrossum Exp $
""" """
# XXX TO DO # XXX TO DO
...@@ -329,12 +329,13 @@ class ClientStorage: ...@@ -329,12 +329,13 @@ class ClientStorage:
raise POSException.ReadOnlyError() raise POSException.ReadOnlyError()
# avoid multiple oid requests to server at the same time # avoid multiple oid requests to server at the same time
self._oid_lock.acquire() self._oid_lock.acquire()
try:
if not self._oids: if not self._oids:
self._oids = self._server.new_oids() self._oids = self._server.new_oids()
self._oids.reverse() self._oids.reverse()
oid = self._oids.pop() return self._oids.pop()
finally:
self._oid_lock.release() self._oid_lock.release()
return oid
def pack(self, t=None, rf=None, wait=0, days=0): def pack(self, t=None, rf=None, wait=0, days=0):
# XXX Is it okay that read-only connections allow pack()? # XXX Is it okay that read-only connections allow pack()?
......
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