Commit 51e177d7 authored by Jeremy Hylton's avatar Jeremy Hylton

Commit the zeo-1_0-debug-branch to the trunk.

I expect this code will become ZEO 1.1.
parent f8e578b8
...@@ -13,22 +13,27 @@ ...@@ -13,22 +13,27 @@
############################################################################## ##############################################################################
"""Network ZODB storage client """Network ZODB storage client
""" """
__version__='$Revision: 1.39 $'[11:-2] __version__='$Revision: 1.40 $'[11:-2]
import struct, time, os, socket, string, Sync, zrpc, ClientCache import struct, time, os, socket, string
import tempfile, Invalidator, ExtensionClass, thread import tempfile, thread
import ThreadedAsync
now=time.time
from struct import pack, unpack from struct import pack, unpack
from types import TupleType
import Invalidator, ExtensionClass
import ThreadedAsync, Sync, zrpc, ClientCache
from ZODB import POSException, BaseStorage from ZODB import POSException, BaseStorage
from ZODB.TimeStamp import TimeStamp from ZODB.TimeStamp import TimeStamp
from zLOG import LOG, PROBLEM, INFO
try: from ZODB.ConflictResolution import ResolvedSerial from ZEO.logger import zLogger
except: ResolvedSerial='rs'
TupleType=type(()) log = zLogger("ZEO Client")
try:
from ZODB.ConflictResolution import ResolvedSerial
except:
ResolvedSerial='rs'
class ClientStorageError(POSException.StorageError): class ClientStorageError(POSException.StorageError):
"""An error occured in the ZEO Client Storage""" """An error occured in the ZEO Client Storage"""
...@@ -63,7 +68,11 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage): ...@@ -63,7 +68,11 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage):
'supportsUndo':0, 'supportsVersions': 0, 'supportsUndo':0, 'supportsVersions': 0,
} }
self._call=zrpc.asyncRPC(connection, debug=debug, if debug:
debug_log = log
else:
debug_log = None
self._call=zrpc.asyncRPC(connection, debug=debug_log,
tmin=min_disconnect_poll, tmin=min_disconnect_poll,
tmax=max_disconnect_poll) tmax=max_disconnect_poll)
...@@ -132,7 +141,7 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage): ...@@ -132,7 +141,7 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage):
# If we can't connect right away, go ahead and open the cache # If we can't connect right away, go ahead and open the cache
# and start a separate thread to try and reconnect. # and start a separate thread to try and reconnect.
LOG("ClientStorage", PROBLEM, "Failed to connect to storage") log.problem("Failed to connect to storage")
self._cache.open() self._cache.open()
thread.start_new_thread(self._call.connect,(0,)) thread.start_new_thread(self._call.connect,(0,))
...@@ -140,7 +149,7 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage): ...@@ -140,7 +149,7 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage):
# notifyConnected # notifyConnected
def notifyConnected(self, s): def notifyConnected(self, s):
LOG("ClientStorage", INFO, "Connected to storage") log.info("Connected to storage")
self._lock_acquire() self._lock_acquire()
try: try:
...@@ -197,7 +206,7 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage): ...@@ -197,7 +206,7 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage):
### responsible for starting the thread that makes the connection. ### responsible for starting the thread that makes the connection.
def notifyDisconnected(self, ignored): def notifyDisconnected(self, ignored):
LOG("ClientStorage", PROBLEM, "Disconnected from storage") log.problem("Disconnected from storage")
self._connected=0 self._connected=0
self._transaction=None self._transaction=None
thread.start_new_thread(self._call.connect,(0,)) thread.start_new_thread(self._call.connect,(0,))
...@@ -233,7 +242,7 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage): ...@@ -233,7 +242,7 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage):
def close(self): def close(self):
self._lock_acquire() self._lock_acquire()
try: try:
LOG("ClientStorage", INFO, "close") log.info("close")
self._call.closeIntensionally() self._call.closeIntensionally()
try: try:
self._tfile.close() self._tfile.close()
...@@ -550,6 +559,9 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage): ...@@ -550,6 +559,9 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage):
def sync(self): self._call.sync() def sync(self): self._call.sync()
def status(self):
self._call.sendMessage('status')
def getWakeup(_w=[]): def getWakeup(_w=[]):
if _w: return _w[0] if _w: return _w[0]
import trigger import trigger
......
This diff is collapsed.
import string
from types import StringType
from zLOG import *
__all__ = ["zLogger", "format_msg"]
_MAX_MSG_SIZE = 120
def format_msg(*args):
accum = []
total_len = 0
for arg in args:
if not isinstance(arg, StringType):
arg = str(arg)
accum.append(arg)
total_len = total_len + len(arg)
if total_len >= _MAX_MSG_SIZE:
break
m = string.join(accum)
if len(m) > _MAX_MSG_SIZE:
m = m[:_MAX_MSG_SIZE] + ' ...'
return m
class zLogger:
def __init__(self, channel):
self.channel = channel
def __str__(self):
raise RuntimeError, "don't print me"
def trace(self, msg):
LOG(self.channel, TRACE, msg)
def debug(self, msg):
LOG(self.channel, DEBUG, msg)
def blather(self, msg):
LOG(self.channel, BLATHER, msg)
def info(self, msg):
LOG(self.channel, INFO, msg)
def problem(self, msg):
LOG(self.channel, PROBLEM, msg)
def warning(self, msg):
LOG(self.channel, WARNING, msg)
def error(self, msg, error=None):
LOG(self.channel, ERROR, msg, error=error)
def panic(self, msg):
LOG(self.channel, PANIC, msg)
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
"""Sized message async connections """Sized message async connections
""" """
__version__ = "$Revision: 1.15 $"[11:-2] __version__ = "$Revision: 1.16 $"[11:-2]
import asyncore, string, struct, zLOG, sys, Acquisition import asyncore, string, struct, zLOG, sys, Acquisition
import socket, errno import socket, errno
from zLOG import LOG, TRACE, ERROR, INFO from logger import zLogger
# Use the dictionary to make sure we get the minimum number of errno # Use the dictionary to make sure we get the minimum number of errno
# entries. We expect that EWOULDBLOCK == EAGAIN on most systems -- # entries. We expect that EWOULDBLOCK == EAGAIN on most systems --
...@@ -48,10 +48,10 @@ class SizedMessageAsyncConnection(Acquisition.Explicit, asyncore.dispatcher): ...@@ -48,10 +48,10 @@ class SizedMessageAsyncConnection(Acquisition.Explicit, asyncore.dispatcher):
SizedMessageAsyncConnection.inheritedAttribute( SizedMessageAsyncConnection.inheritedAttribute(
'__init__')(self, sock, map) '__init__')(self, sock, map)
self.addr=addr self.addr=addr
if debug is not None: if debug is None and __debug__:
self._debug=debug self._debug = zLogger("smac")
elif not hasattr(self, '_debug'): else:
self._debug=__debug__ and 'smac' self._debug = debug
self.__state=None self.__state=None
self.__inp=None self.__inp=None
self.__inpl=0 self.__inpl=0
...@@ -132,10 +132,12 @@ class SizedMessageAsyncConnection(Acquisition.Explicit, asyncore.dispatcher): ...@@ -132,10 +132,12 @@ class SizedMessageAsyncConnection(Acquisition.Explicit, asyncore.dispatcher):
def message_output(self, message, def message_output(self, message,
pack=struct.pack, len=len): pack=struct.pack, len=len):
if self._debug: if self._debug is not None:
if len(message) > 40: m=message[:40]+' ...' if len(message) > 40:
else: m=message m = message[:40]+' ...'
LOG(self._debug, TRACE, 'message_output %s' % `m`) else:
m = message
self._debug.trace('message_output %s' % `m`)
append=self.__append append=self.__append
if append is None: if append is None:
...@@ -143,13 +145,6 @@ class SizedMessageAsyncConnection(Acquisition.Explicit, asyncore.dispatcher): ...@@ -143,13 +145,6 @@ class SizedMessageAsyncConnection(Acquisition.Explicit, asyncore.dispatcher):
append(pack(">i",len(message))+message) append(pack(">i",len(message))+message)
def log_info(self, message, type='info'):
if type=='error': type=ERROR
else: type=INFO
LOG('ZEO', type, message)
log=log_info
def close(self): def close(self):
if self.__append is not None: if self.__append is not None:
self.__append=None self.__append=None
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
"""Start the server storage. """Start the server storage.
""" """
__version__ = "$Revision: 1.30 $"[11:-2] __version__ = "$Revision: 1.31 $"[11:-2]
import sys, os, getopt, string import sys, os, getopt, string
...@@ -75,11 +75,9 @@ def main(argv): ...@@ -75,11 +75,9 @@ def main(argv):
os.path.join(var, 'ZEO_SERVER.pid') os.path.join(var, 'ZEO_SERVER.pid')
) )
opts, args = getopt.getopt(args, 'p:Ddh:U:sS:u:') fs = os.path.join(var, 'Data.fs')
fs=os.path.join(var, 'Data.fs')
usage="""%s [options] [filename] usage = """%s [options] [filename]
where options are: where options are:
...@@ -121,6 +119,13 @@ def main(argv): ...@@ -121,6 +119,13 @@ def main(argv):
if no file name is specified, then %s is used. if no file name is specified, then %s is used.
""" % (me, fs) """ % (me, fs)
try:
opts, args = getopt.getopt(args, 'p:Ddh:U:sS:u:')
except getopt.error, err:
print err
print usage
sys.exit(1)
port=None port=None
debug=detailed=0 debug=detailed=0
host='' host=''
...@@ -217,15 +222,15 @@ def main(argv): ...@@ -217,15 +222,15 @@ def main(argv):
import signal import signal
signal.signal(signal.SIGTERM, signal.signal(signal.SIGTERM,
lambda sig, frame, s=storages: shutdown(s) lambda sig, frame, s=storages: shutdown(s))
)
signal.signal(signal.SIGINT, signal.signal(signal.SIGINT,
lambda sig, frame, s=storages: shutdown(s, 0) lambda sig, frame, s=storages: shutdown(s, 0))
) try:
try: signal.signal(signal.SIGHUP, rotate_logs_handler) signal.signal(signal.SIGHUP, rotate_logs_handler)
except: pass except:
pass
except: pass except:
pass
items=storages.items() items=storages.items()
items.sort() items.sort()
...@@ -236,13 +241,16 @@ def main(argv): ...@@ -236,13 +241,16 @@ def main(argv):
ZEO.StorageServer.StorageServer(unix, storages) ZEO.StorageServer.StorageServer(unix, storages)
try: ppid, pid = os.getppid(), os.getpid() try:
except: pass # getpid not supported ppid, pid = os.getppid(), os.getpid()
else: open(zeo_pid,'w').write("%s %s" % (ppid, pid)) except:
pass # getpid not supported
else:
open(zeo_pid,'w').write("%s %s" % (ppid, pid))
except: except:
# Log startup exception and tell zdaemon not to restart us. # Log startup exception and tell zdaemon not to restart us.
info=sys.exc_info() info = sys.exc_info()
try: try:
import zLOG import zLOG
zLOG.LOG("z2", zLOG.PANIC, "Startup exception", zLOG.LOG("z2", zLOG.PANIC, "Startup exception",
...@@ -280,21 +288,29 @@ def shutdown(storages, die=1): ...@@ -280,21 +288,29 @@ def shutdown(storages, die=1):
# unnecessary, since we now use so_reuseaddr. # unnecessary, since we now use so_reuseaddr.
for ignored in 1,2: for ignored in 1,2:
for socket in asyncore.socket_map.values(): for socket in asyncore.socket_map.values():
try: socket.close() try:
except: pass socket.close()
except:
pass
for storage in storages.values(): for storage in storages.values():
try: storage.close() try:
except: pass storage.close()
except:
pass
try: try:
from zLOG import LOG, INFO from zLOG import LOG, INFO
LOG('ZEO Server', INFO, LOG('ZEO Server', INFO,
"Shutting down (%s)" % (die and "shutdown" or "restart") "Shutting down (%s)" % (die and "shutdown" or "restart")
) )
except: pass except:
pass
if die: sys.exit(0) if die:
else: sys.exit(1) sys.exit(0)
else:
sys.exit(1)
if __name__=='__main__': main(sys.argv) if __name__ == '__main__':
main(sys.argv)
...@@ -172,6 +172,7 @@ class GenericTests(ZEOTestBase, ...@@ -172,6 +172,7 @@ class GenericTests(ZEOTestBase,
def tearDown(self): def tearDown(self):
"""Try to cause the tests to halt""" """Try to cause the tests to halt"""
self.running = 0 self.running = 0
self._storage.status()
self._storage.close() self._storage.close()
self._server.close() self._server.close()
os.waitpid(self._pid, 0) os.waitpid(self._pid, 0)
...@@ -218,6 +219,7 @@ class GenericTests(ZEOTestBase, ...@@ -218,6 +219,7 @@ class GenericTests(ZEOTestBase,
oid = self._storage.new_oid() oid = self._storage.new_oid()
self._storage.store(oid, None, '', '', t) self._storage.store(oid, None, '', '', t)
self._storage.tpc_vote(t) self._storage.tpc_vote(t)
self._storage.status()
self._storage.tpc_finish(t) self._storage.tpc_finish(t)
for store, trans in self._storages: for store, trans in self._storages:
...@@ -237,7 +239,7 @@ class GenericTests(ZEOTestBase, ...@@ -237,7 +239,7 @@ class GenericTests(ZEOTestBase,
def _get_timestamp(self): def _get_timestamp(self):
t = time.time() t = time.time()
t = apply(TimeStamp,(time.gmtime(t)[:5]+(t%60,))) t = apply(TimeStamp,(time.gmtime(t)[:5]+(t%60,)))
return 't' return `t`
class ZEOFileStorageTests(GenericTests): class ZEOFileStorageTests(GenericTests):
__super_setUp = GenericTests.setUp __super_setUp = GenericTests.setUp
......
...@@ -15,10 +15,8 @@ ...@@ -15,10 +15,8 @@
# This module is a simplified version of the select_trigger module # This module is a simplified version of the select_trigger module
# from Sam Rushing's Medusa server. # from Sam Rushing's Medusa server.
import asyncore import asyncore
#import asynchat import errno
import os import os
import socket import socket
import string import string
...@@ -26,7 +24,7 @@ import thread ...@@ -26,7 +24,7 @@ import thread
if os.name == 'posix': if os.name == 'posix':
class trigger (asyncore.file_dispatcher): class trigger(asyncore.file_dispatcher):
"Wake up a call to select() running in the main thread" "Wake up a call to select() running in the main thread"
...@@ -58,10 +56,10 @@ if os.name == 'posix': ...@@ -58,10 +56,10 @@ if os.name == 'posix':
# new data onto a channel's outgoing data queue at the same time that # new data onto a channel's outgoing data queue at the same time that
# the main thread is trying to remove some] # the main thread is trying to remove some]
def __init__ (self): def __init__(self):
r, w = self._fds = os.pipe() r, w = self._fds = os.pipe()
self.trigger = w self.trigger = w
asyncore.file_dispatcher.__init__ (self, r) asyncore.file_dispatcher.__init__(self, r)
self.lock = thread.allocate_lock() self.lock = thread.allocate_lock()
self.thunks = [] self.thunks = []
...@@ -69,30 +67,35 @@ if os.name == 'posix': ...@@ -69,30 +67,35 @@ if os.name == 'posix':
os.close(self._fds[0]) os.close(self._fds[0])
os.close(self._fds[1]) os.close(self._fds[1])
def __repr__ (self): def __repr__(self):
return '<select-trigger (pipe) at %x>' % id(self) return '<select-trigger(pipe) at %x>' % id(self)
def readable (self): def readable(self):
return 1 return 1
def writable (self): def writable(self):
return 0 return 0
def handle_connect (self): def handle_connect(self):
pass pass
def pull_trigger (self, thunk=None): def pull_trigger(self, thunk=None):
# print 'PULL_TRIGGER: ', len(self.thunks) # print 'PULL_TRIGGER: ', len(self.thunks)
if thunk: if thunk:
try: try:
self.lock.acquire() self.lock.acquire()
self.thunks.append (thunk) self.thunks.append(thunk)
finally: finally:
self.lock.release() self.lock.release()
os.write (self.trigger, 'x') os.write(self.trigger, 'x')
def handle_read (self): def handle_read(self):
self.recv (8192) try:
self.recv(8192)
except os.error, err:
if err[0] == errno.EAGAIN: # resource temporarily unavailable
return
raise
try: try:
self.lock.acquire() self.lock.acquire()
for thunk in self.thunks: for thunk in self.thunks:
...@@ -101,7 +104,7 @@ if os.name == 'posix': ...@@ -101,7 +104,7 @@ if os.name == 'posix':
except: except:
nil, t, v, tbinfo = asyncore.compact_traceback() nil, t, v, tbinfo = asyncore.compact_traceback()
print ('exception in trigger thunk:' print ('exception in trigger thunk:'
' (%s:%s %s)' % (t, v, tbinfo)) '(%s:%s %s)' % (t, v, tbinfo))
self.thunks = [] self.thunks = []
finally: finally:
self.lock.release() self.lock.release()
...@@ -113,13 +116,13 @@ else: ...@@ -113,13 +116,13 @@ else:
# win32-safe version # win32-safe version
class trigger (asyncore.dispatcher): class trigger(asyncore.dispatcher):
address = ('127.9.9.9', 19999) address = ('127.9.9.9', 19999)
def __init__ (self): def __init__(self):
a = socket.socket (socket.AF_INET, socket.SOCK_STREAM) a = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
w = socket.socket (socket.AF_INET, socket.SOCK_STREAM) w = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# set TCP_NODELAY to true to avoid buffering # set TCP_NODELAY to true to avoid buffering
w.setsockopt(socket.IPPROTO_TCP, 1, 1) w.setsockopt(socket.IPPROTO_TCP, 1, 1)
...@@ -137,45 +140,50 @@ else: ...@@ -137,45 +140,50 @@ else:
raise 'Bind Error', 'Cannot bind trigger!' raise 'Bind Error', 'Cannot bind trigger!'
port=port - 1 port=port - 1
a.listen (1) a.listen(1)
w.setblocking (0) w.setblocking(0)
try: try:
w.connect (self.address) w.connect(self.address)
except: except:
pass pass
r, addr = a.accept() r, addr = a.accept()
a.close() a.close()
w.setblocking (1) w.setblocking(1)
self.trigger = w self.trigger = w
asyncore.dispatcher.__init__ (self, r) asyncore.dispatcher.__init__(self, r)
self.lock = thread.allocate_lock() self.lock = thread.allocate_lock()
self.thunks = [] self.thunks = []
self._trigger_connected = 0 self._trigger_connected = 0
def __repr__ (self): def __repr__(self):
return '<select-trigger (loopback) at %x>' % id(self) return '<select-trigger (loopback) at %x>' % id(self)
def readable (self): def readable(self):
return 1 return 1
def writable (self): def writable(self):
return 0 return 0
def handle_connect (self): def handle_connect(self):
pass pass
def pull_trigger (self, thunk=None): def pull_trigger(self, thunk=None):
if thunk: if thunk:
try: try:
self.lock.acquire() self.lock.acquire()
self.thunks.append (thunk) self.thunks.append(thunk)
finally: finally:
self.lock.release() self.lock.release()
self.trigger.send ('x') self.trigger.send('x')
def handle_read (self): def handle_read(self):
self.recv (8192) try:
self.recv(8192)
except os.error, err:
if err[0] == errno.EAGAIN: # resource temporarily unavailable
return
raise
try: try:
self.lock.acquire() self.lock.acquire()
for thunk in self.thunks: for thunk in self.thunks:
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
"""Simple rpc mechanisms """Simple rpc mechanisms
""" """
__version__ = "$Revision: 1.22 $"[11:-2] __version__ = "$Revision: 1.23 $"[11:-2]
from cPickle import loads from cPickle import loads
import cPickle import cPickle
...@@ -61,12 +61,12 @@ class asyncRPC(SizedMessageAsyncConnection): ...@@ -61,12 +61,12 @@ class asyncRPC(SizedMessageAsyncConnection):
self.__call_la=l.acquire self.__call_la=l.acquire
self.__call_lr=l.release self.__call_lr=l.release
def connect(self, tryonce=1, log_type='client'): def connect(self, tryonce=1):
t=self._tmin t=self._tmin
connection = self._connection connection = self._connection
debug=self._debug debug=self._debug
while self.__closed == 0: while self.__closed == 0:
if log_type: LOG(log_type, INFO, LOG("client", INFO,
'Trying to connect to server: %s' % `connection`) 'Trying to connect to server: %s' % `connection`)
try: try:
if type(connection) is type(''): if type(connection) is type(''):
...@@ -75,15 +75,15 @@ class asyncRPC(SizedMessageAsyncConnection): ...@@ -75,15 +75,15 @@ class asyncRPC(SizedMessageAsyncConnection):
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(connection) s.connect(connection)
except Exception, err: except Exception, err:
if debug: if debug is not None:
LOG(debug, DEBUG, "Failed to connect to server: %s" % err) debug.blather("Failed to connect to server: %s" % err)
if tryonce: return 0 if tryonce: return 0
time.sleep(t) time.sleep(t)
t=t*2 t=t*2
if t > self._tmax: t=self._tmax if t > self._tmax: t=self._tmax
else: else:
if debug: if debug is not None:
LOG(debug, DEBUG, "Connected to server") debug.blather("Connected to server")
# Make sure the result lock is set, se we don't # Make sure the result lock is set, se we don't
# get an old result (e.g. the exception that # get an old result (e.g. the exception that
...@@ -199,12 +199,12 @@ class asyncRPC(SizedMessageAsyncConnection): ...@@ -199,12 +199,12 @@ class asyncRPC(SizedMessageAsyncConnection):
self._outOfBand=f self._outOfBand=f
def message_input(self, m): def message_input(self, m):
if self._debug: if self._debug is not None:
if len(m) > 60: if len(m) > 60:
md = repr(m[:60]) + ' ...' md = repr(m[:60]) + ' ...'
else: else:
md = repr(m) md = repr(m)
LOG(self._debug, TRACE, 'message_input %s' % md) self._debug.trace('message_input %s' % md)
c=m[:1] c=m[:1]
if c in 'RE': if c in 'RE':
......
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
"""Sized message async connections """Sized message async connections
""" """
__version__ = "$Revision: 1.15 $"[11:-2] __version__ = "$Revision: 1.16 $"[11:-2]
import asyncore, string, struct, zLOG, sys, Acquisition import asyncore, string, struct, zLOG, sys, Acquisition
import socket, errno import socket, errno
from zLOG import LOG, TRACE, ERROR, INFO from logger import zLogger
# Use the dictionary to make sure we get the minimum number of errno # Use the dictionary to make sure we get the minimum number of errno
# entries. We expect that EWOULDBLOCK == EAGAIN on most systems -- # entries. We expect that EWOULDBLOCK == EAGAIN on most systems --
...@@ -48,10 +48,10 @@ class SizedMessageAsyncConnection(Acquisition.Explicit, asyncore.dispatcher): ...@@ -48,10 +48,10 @@ class SizedMessageAsyncConnection(Acquisition.Explicit, asyncore.dispatcher):
SizedMessageAsyncConnection.inheritedAttribute( SizedMessageAsyncConnection.inheritedAttribute(
'__init__')(self, sock, map) '__init__')(self, sock, map)
self.addr=addr self.addr=addr
if debug is not None: if debug is None and __debug__:
self._debug=debug self._debug = zLogger("smac")
elif not hasattr(self, '_debug'): else:
self._debug=__debug__ and 'smac' self._debug = debug
self.__state=None self.__state=None
self.__inp=None self.__inp=None
self.__inpl=0 self.__inpl=0
...@@ -132,10 +132,12 @@ class SizedMessageAsyncConnection(Acquisition.Explicit, asyncore.dispatcher): ...@@ -132,10 +132,12 @@ class SizedMessageAsyncConnection(Acquisition.Explicit, asyncore.dispatcher):
def message_output(self, message, def message_output(self, message,
pack=struct.pack, len=len): pack=struct.pack, len=len):
if self._debug: if self._debug is not None:
if len(message) > 40: m=message[:40]+' ...' if len(message) > 40:
else: m=message m = message[:40]+' ...'
LOG(self._debug, TRACE, 'message_output %s' % `m`) else:
m = message
self._debug.trace('message_output %s' % `m`)
append=self.__append append=self.__append
if append is None: if append is None:
...@@ -143,13 +145,6 @@ class SizedMessageAsyncConnection(Acquisition.Explicit, asyncore.dispatcher): ...@@ -143,13 +145,6 @@ class SizedMessageAsyncConnection(Acquisition.Explicit, asyncore.dispatcher):
append(pack(">i",len(message))+message) append(pack(">i",len(message))+message)
def log_info(self, message, type='info'):
if type=='error': type=ERROR
else: type=INFO
LOG('ZEO', type, message)
log=log_info
def close(self): def close(self):
if self.__append is not None: if self.__append is not None:
self.__append=None self.__append=None
......
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