summaryrefslogtreecommitdiff
path: root/python/qpid/connection08.py
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2012-11-07 12:27:56 +0000
committerKeith Wall <kwall@apache.org>2012-11-07 12:27:56 +0000
commit016d15ba1964e51f145320f15b1f796006b66dce (patch)
tree292514b827ec73c49578edbc795e3c188eeb453f /python/qpid/connection08.py
parentf82467cf38d4fbc45cbaa06906420e84ccbb088b (diff)
downloadqpid-python-016d15ba1964e51f145320f15b1f796006b66dce.tar.gz
QPID-4422: Python Client (0-8..0-9) now allows "instance" client property to be passed in order to allow re-subscribing to durable subscriptions. Centralised the creation of client properties such that this is only done in one place across all protocols. Also increased Python Client (0-8..0-9)'s diagnostic logging.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1406584 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/connection08.py')
-rw-r--r--python/qpid/connection08.py41
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)