diff options
author | Kim van der Riet <kpvdr@apache.org> | 2013-02-28 16:14:30 +0000 |
---|---|---|
committer | Kim van der Riet <kpvdr@apache.org> | 2013-02-28 16:14:30 +0000 |
commit | 9c73ef7a5ac10acd6a50d5d52bd721fc2faa5919 (patch) | |
tree | 2a890e1df09e5b896a9b4168a7b22648f559a1f2 /python/qpid/connection08.py | |
parent | 172d9b2a16cfb817bbe632d050acba7e31401cd2 (diff) | |
download | qpid-python-asyncstore.tar.gz |
Update from trunk r1375509 through r1450773asyncstore
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/asyncstore@1451244 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/connection08.py')
-rw-r--r-- | python/qpid/connection08.py | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/python/qpid/connection08.py b/python/qpid/connection08.py index 654148dad2..0045e122ea 100644 --- a/python/qpid/connection08.py +++ b/python/qpid/connection08.py @@ -28,6 +28,9 @@ from cStringIO import StringIO from codec import EOF from compat import SHUT_RDWR from exceptions import VersionError +from logging import getLogger, DEBUG + +log = getLogger("qpid.connection08") class SockIO: @@ -35,7 +38,8 @@ class SockIO: self.sock = sock def write(self, buf): -# print "OUT: %r" % buf + if log.isEnabledFor(DEBUG): + log.debug("OUT: %r", buf) self.sock.sendall(buf) def read(self, n): @@ -47,8 +51,9 @@ class SockIO: break if len(s) == 0: break -# print "IN: %r" % s data += s + if log.isEnabledFor(DEBUG): + log.debug("IN: %r", data) return data def flush(self): @@ -120,19 +125,25 @@ class Connection: (self.spec.major, self.spec.minor, major, minor)) else: raise FramingError("unknown frame type: %s" % tid) - channel = c.decode_short() - body = c.decode_longstr() - dec = codec.Codec(StringIO(body), self.spec) - frame = Frame.DECODERS[type].decode(self.spec, dec, len(body)) - frame.channel = channel - end = c.decode_octet() - if end != self.FRAME_END: - garbage = "" - while end != self.FRAME_END: - garbage += chr(end) - end = c.decode_octet() - raise "frame error: expected %r, got %r" % (self.FRAME_END, garbage) - return frame + try: + channel = c.decode_short() + body = c.decode_longstr() + dec = codec.Codec(StringIO(body), self.spec) + frame = Frame.DECODERS[type].decode(self.spec, dec, len(body)) + frame.channel = channel + end = c.decode_octet() + if end != self.FRAME_END: + garbage = "" + while end != self.FRAME_END: + garbage += chr(end) + end = c.decode_octet() + raise "frame error: expected %r, got %r" % (self.FRAME_END, garbage) + return frame + except EOF: + # An EOF caught here can indicate an error decoding the frame, + # rather than that a disconnection occurred,so it's worth logging it. + log.exception("Error occurred when reading frame with tid %s" % tid) + raise def write_0_9(self, frame): self.write_8_0(frame) |