[Zope3-checkins] CVS: Zope3/lib/python/ZEO - StorageServer.py:1.45
Guido van Rossum
guido@python.org
Thu, 19 Dec 2002 14:38:06 -0500
Update of /cvs-repository/Zope3/lib/python/ZEO
In directory cvs.zope.org:/tmp/cvs-serv19547
Modified Files:
StorageServer.py
Log Message:
Logging improvements ported from the 3.1 release branch.
=== Zope3/lib/python/ZEO/StorageServer.py 1.44 => 1.45 ===
--- Zope3/lib/python/ZEO/StorageServer.py:1.44 Tue Nov 26 17:50:32 2002
+++ Zope3/lib/python/ZEO/StorageServer.py Thu Dec 19 14:38:05 2002
@@ -211,10 +211,18 @@
self.storage_id = "uninitialized"
self.transaction = None
self.read_only = read_only
+ self.log_label = _label
def notifyConnected(self, conn):
self.connection = conn # For restart_other() below
self.client = self.ClientStorageStubClass(conn)
+ addr = conn.addr
+ if isinstance(addr, type("")):
+ label = addr
+ else:
+ host, port = addr
+ label = str(host) + ":" + str(port)
+ self.log_label = _label + "/" + label
def notifyDisconnected(self):
# When this storage closes, we must ensure that it aborts
@@ -236,7 +244,7 @@
return "<%s %X trans=%s s_trans=%s>" % (name, id(self), tid, stid)
def log(self, msg, level=zLOG.INFO, error=None):
- zLOG.LOG("%s:%s" % (_label, self.storage_id), level, msg, error=error)
+ zLOG.LOG(self.log_label, level, msg, error=error)
def setup_delegation(self):
"""Delegate several methods to the storage"""
@@ -285,7 +293,7 @@
This method must be the first one called by the client.
"""
if self.storage is not None:
- log("duplicate register() call")
+ self.log("duplicate register() call")
raise ValueError, "duplicate register() call"
storage = self.server.storages.get(storage_id)
if storage is None:
@@ -537,7 +545,8 @@
old_strategy = self.strategy
assert isinstance(old_strategy, DelayedCommitStrategy)
self.strategy = ImmediateCommitStrategy(self.storage,
- self.client)
+ self.client,
+ self.log)
resp = old_strategy.restart(self.strategy)
if delay is not None:
delay.reply(resp)
@@ -593,11 +602,12 @@
class ImmediateCommitStrategy:
"""The storage is available so do a normal commit."""
- def __init__(self, storage, client):
+ def __init__(self, storage, client, logmethod):
self.storage = storage
self.client = client
self.invalidated = []
self.serials = []
+ self.log = logmethod
def tpc_begin(self, txn, tid, status):
self.txn = txn
@@ -619,12 +629,14 @@
try:
newserial = self.storage.store(oid, serial, data, version,
self.txn)
+ except (SystemExit, KeyboardInterrupt):
+ raise
except Exception, err:
if not isinstance(err, TransactionError):
# Unexpected errors are logged and passed to the client
exc_info = sys.exc_info()
- log("store error: %s, %s" % exc_info[:2],
- zLOG.ERROR, error=exc_info)
+ self.log("store error: %s, %s" % exc_info[:2],
+ zLOG.ERROR, error=exc_info)
del exc_info
# Try to pickle the exception. If it can't be pickled,
# the RPC response would fail, so use something else.
@@ -634,7 +646,7 @@
pickler.dump(err, 1)
except:
msg = "Couldn't pickle storage exception: %s" % repr(err)
- log(msg, zLOG.ERROR)
+ self.log(msg, zLOG.ERROR)
err = StorageServerError(msg)
# The exception is reported back as newserial for this oid
newserial = err
@@ -767,6 +779,8 @@
def run(self):
try:
result = self._method(*self._args)
+ except (SystemExit, KeyboardInterrupt):
+ raise
except Exception:
self.delay.error(sys.exc_info())
else: