[Zodb-checkins] CVS: StandaloneZODB/ZEO - ClientCache.py:1.14.4.6 ClientStorage.py:1.26.4.26 StorageServer.py:1.21.4.14 zrpc2.py:1.1.2.20

Jeremy Hylton jeremy@zope.com
Thu, 3 Jan 2002 19:48:40 -0500


Update of /cvs-repository/StandaloneZODB/ZEO
In directory cvs.zope.org:/tmp/cvs-serv30673

Modified Files:
      Tag: ZEO-ZRPC-Dev
	ClientCache.py ClientStorage.py StorageServer.py zrpc2.py 
Log Message:
Restore use of zLOG instead of zeolog.

The performance issues that lead me to use zeolog in the first place
have been fixed in zLOG.

Also add helpful comment about where exception came from in zrpc2.



=== StandaloneZODB/ZEO/ClientCache.py 1.14.4.5 => 1.14.4.6 ===
 
 import sys
-import zeolog
+import zLOG
 
-def log(msg, level=zeolog.INFO):
-    zeolog.LOG("ZEC", level, msg)
+def log(msg, level=zLOG.INFO):
+    zLOG.LOG("ZEC", level, msg)
 
 magic='ZEC0'
 


=== StandaloneZODB/ZEO/ClientStorage.py 1.26.4.25 => 1.26.4.26 ===
 from ZODB import POSException
 from ZODB.TimeStamp import TimeStamp
-from zeolog import LOG, PROBLEM, INFO, BLATHER
+from zLOG import LOG, PROBLEM, INFO, BLATHER
 from Exceptions import Disconnected
 
 def log2(type, msg, subsys="ClientStorage %d" % os.getpid()):


=== StandaloneZODB/ZEO/StorageServer.py 1.21.4.13 => 1.21.4.14 ===
 import ClientStub
 import zrpc2
-import zeolog
+import zLOG
 
 from zrpc2 import Dispatcher, Handler, ManagedServerConnection, Delay
 from ZODB.POSException import StorageError, StorageTransactionError, \
@@ -114,9 +114,9 @@
 pickler.fast = 1 # Don't use the memo
 dump = pickler.dump
 
-def log(message, level=zeolog.INFO, label="ZEO Server:%s" % os.getpid(),
+def log(message, level=zLOG.INFO, label="ZEO Server:%s" % os.getpid(),
         error=None):
-    zeolog.LOG(label, level, message, error=error)
+    zLOG.LOG(label, level, message, error=error)
 
 class StorageServerError(StorageError):
     pass
@@ -180,8 +180,8 @@
         return "<StorageProxy %X trans=%s s_trans=%s>" % (id(self), tid,
                                                           stid)
 
-    def _log(self, msg, level=zeolog.INFO, error=None, pid=os.getpid()):
-        zeolog.LOG("ZEO Server %s %X" % (pid, id(self)),
+    def _log(self, msg, level=zLOG.INFO, error=None, pid=os.getpid()):
+        zLOG.LOG("ZEO Server %s %X" % (pid, id(self)),
                    level, msg, error=error)
 
     def setup_delegation(self):
@@ -198,7 +198,7 @@
         caller = sys._getframe().f_back.f_code.co_name
         if self._transaction is None:
             self._log("no current transaction: %s()" % caller,
-                zeolog.PROBLEM)
+                zLOG.PROBLEM)
             if exc is not None:
                 raise exc(None, tid)
             else:
@@ -206,7 +206,7 @@
         if self._transaction.id != tid:
             self._log("%s(%s) invalid; current transaction = %s" % \
                 (caller, repr(tid), repr(self._transaction.id)),
-                zeolog.PROBLEM)
+                zLOG.PROBLEM)
             if exc is not None:
                 raise exc(self._transaction.id, tid)
             else:
@@ -285,7 +285,7 @@
         try: 
             self.__storage.pack(t, referencesf)
         except:
-            self._log('ZEO Server', zeolog.ERROR,
+            self._log('ZEO Server', zLOG.ERROR,
                       'Pack failed for %s' % self.__storage_id,
                       error=sys.exc_info())
             if wait:
@@ -331,7 +331,7 @@
             # IOW, Anything that ends up here is evil enough to be logged.
             error = sys.exc_info()
             self._log('store error: %s: %s' % (error[0], error[1]),
-                      zeolog.ERROR, error=error)
+                      zLOG.ERROR, error=error)
             newserial = sys.exc_info()[1]
         else:
             if serial != '\0\0\0\0\0\0\0\0':
@@ -341,7 +341,7 @@
             nil = dump(newserial, 1)
         except:
             self._log("couldn't pickle newserial: %s" % repr(newserial),
-                      zeolog.ERROR)
+                      zLOG.ERROR)
             dump('', 1) # clear pickler
             r = StorageServerError("Couldn't pickle exception %s" % \
                                    `newserial`)


=== StandaloneZODB/ZEO/zrpc2.py 1.1.2.19 => 1.1.2.20 ===
 from ZEO import smac, trigger
 from Exceptions import Disconnected
-import zeolog
+import zLOG
 import ThreadedAsync
 from Exceptions import Disconnected
 
@@ -49,8 +49,8 @@
     global _label
     _label = "zrpc:%s" % os.getpid()
 
-def log(message, level=zeolog.BLATHER, label=None, error=None):
-    zeolog.LOG(label or _label, level, message, error=error)
+def log(message, level=zLOG.BLATHER, label=None, error=None):
+    zLOG.LOG(label or _label, level, message, error=error)
 
 class ZRPCError(POSException.StorageError):
     pass
@@ -107,7 +107,7 @@
             return unpickler.load() # msgid, flags, name, args
             msgid, flags, name, args = unpickler.load()
         except (cPickle.UnpicklingError, IndexError), err_msg:
-            log("can't decode %s" % repr(msg), level=zeolog.ERROR)
+            log("can't decode %s" % repr(msg), level=zLOG.ERROR)
             raise DecodingError(msg)
 
 class Delay:
@@ -189,7 +189,7 @@
         if __debug__:
             log("recv msg: %s, %s, %s, %s" % (msgid, flags, name,
                                               repr(args)[:40]),
-                level=zeolog.DEBUG)
+                level=zLOG.DEBUG)
         if name == REPLY:
             self.handle_reply(msgid, flags, args)
         else:
@@ -198,14 +198,14 @@
     def handle_reply(self, msgid, flags, args):
         if __debug__:
             log("recv reply: %s, %s, %s" % (msgid, flags, str(args)[:40]),
-                level=zeolog.DEBUG)
+                level=zLOG.DEBUG)
         self.__reply = msgid, flags, args
         self.__reply_lock.release() # will fail if lock is unlocked
 
     def handle_request(self, msgid, flags, name, args):
         if __debug__:
             log("call %s%s on %s" % (name, repr(args)[:40], repr(self.obj)),
-                zeolog.DEBUG)
+                zLOG.DEBUG)
         if not self.check_method(name):
             raise ZRPCError("Invalid method name: %s on %s" % (name,
                                                                `self.obj`))
@@ -223,21 +223,21 @@
         except (POSException.UndoError,
                 POSException.VersionCommitError), msg:
             error = sys.exc_info()
-            log("%s() raised exception: %s" % (name, msg), zeolog.ERROR, error)
+            log("%s() raised exception: %s" % (name, msg), zLOG.ERROR, error)
             return self.return_error(msgid, flags, error[0], error[1])
         except Exception, msg:
             error = sys.exc_info()
-            log("%s() raised exception: %s" % (name, msg), zeolog.ERROR, error)
+            log("%s() raised exception: %s" % (name, msg), zLOG.ERROR, error)
             return self.return_error(msgid, flags, error[0], error[1])
 
         if flags & ASYNC:
             if ret is not None:
                 log("async method %s returned value %s" % (name, repr(ret)),
-                    zeolog.ERROR)
+                    zLOG.ERROR)
                 raise ZRPCError("async method returned value")
         else:
             if __debug__:
-                log("%s return %s" % (name, repr(ret)[:40]), zeolog.DEBUG)
+                log("%s return %s" % (name, repr(ret)[:40]), zLOG.DEBUG)
             if isinstance(ret, Delay):
                 ret.set_sender(msgid, self.send_reply)
             else:
@@ -249,7 +249,7 @@
 
     def log_error(self, msg="No error message supplied"):
         error = sys.exc_info()
-        log(msg, zeolog.ERROR, error=error)
+        log(msg, zLOG.ERROR, error=error)
         del error
 
     def check_method(self, name):
@@ -311,7 +311,7 @@
         if type(r_args) == types.TupleType \
            and type(r_args[0]) == types.ClassType \
            and issubclass(r_args[0], Exception):
-            raise r_args[1]
+            raise r_args[1] # error raised by server
         return r_args
 
     def callAsync(self, method, *args):
@@ -357,7 +357,7 @@
 
         if __debug__:
             log("_do_io(wait=%d), async=%d" % (wait, self.is_async()),
-                level=zeolog.DEBUG)
+                level=zLOG.DEBUG)
         if self.is_async():
             self.trigger.pull_trigger()
             if wait:
@@ -466,7 +466,7 @@
                         t = self._wait(t)
                 else:
                     if self.debug:
-                        log("Connected to server", level=zeolog.DEBUG)
+                        log("Connected to server", level=zLOG.DEBUG)
                     self.connected = 1
             if self.connected and not self.closed:
                 c = ManagedConnection(s, self.addr, self.obj, self)
@@ -491,7 +491,7 @@
         except socket.error, msg:
             if self.debug:
                 log("Failed to connect to server: %s" % msg,
-                    level=zeolog.DEBUG)
+                    level=zLOG.DEBUG)
             s.close()
             return None
         return s