Commit d6730dbb authored by Jeremy Hylton's avatar Jeremy Hylton

Add end_transaction() method.

Use this method to set self._transaction to None and notify another
thread.
parent c67abb1b
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
############################################################################## ##############################################################################
"""Network ZODB storage client """Network ZODB storage client
$Id: ClientStorage.py,v 1.50 2002/08/16 22:49:40 jeremy Exp $ $Id: ClientStorage.py,v 1.51 2002/08/16 22:55:44 jeremy Exp $
""" """
import cPickle import cPickle
...@@ -351,16 +351,21 @@ class ClientStorage: ...@@ -351,16 +351,21 @@ class ClientStorage:
except: except:
# Client may have disconnected during the tpc_begin(). # Client may have disconnected during the tpc_begin().
if self._server is not disconnected_stub: if self._server is not disconnected_stub:
self.tpc_cond.acquire() self.end_transaction()
self._transaction = None
self.tpc_cond.notify()
self.tpc_cond.release()
raise raise
self._serial = id self._serial = id
self._seriald.clear() self._seriald.clear()
del self._serials[:] 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): def tpc_abort(self, transaction):
if transaction is not self._transaction: if transaction is not self._transaction:
return return
...@@ -370,10 +375,7 @@ class ClientStorage: ...@@ -370,10 +375,7 @@ class ClientStorage:
self._seriald.clear() self._seriald.clear()
del self._serials[:] del self._serials[:]
finally: finally:
self.tpc_cond.acquire() self.end_transaction()
self._transaction = None
self.tpc_cond.notify()
self.tpc_cond.release()
def tpc_finish(self, transaction, f=None): def tpc_finish(self, transaction, f=None):
if transaction is not self._transaction: if transaction is not self._transaction:
...@@ -389,10 +391,7 @@ class ClientStorage: ...@@ -389,10 +391,7 @@ class ClientStorage:
self._update_cache() self._update_cache()
finally: finally:
self.tpc_cond.acquire() self.end_transaction()
self._transaction = None
self.tpc_cond.notify()
self.tpc_cond.release()
def _update_cache(self): def _update_cache(self):
# Iterate over the objects in the transaction buffer and # Iterate over the objects in the transaction buffer and
......
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