txamqp-user team mailing list archive
-
txamqp-user team
-
Mailing list archive
-
Message #00000
Weird error in protocol
Hey,
I've been playing with txamqp lately and I think I find a bug in the
frame handling code.
I wrote a small program that send hello world message to a fanout
exchange and a consumer that read messages from the queue.
When sending a lot of messages it seems that some incorrectly handled
error occur in the frame parsing code in FrameReceiver._unpackFrame
It raises a struct.error which is handled with except but the code
return the data (str) and ignore the error. The normal function
execution would have returned a Frame object.
Then frame.channel is called on the string in frameReceived method
raising an exceptions.AttributeError: 'str' object has no attribute
'channel'
If I re-raise the struct.error I got this :
struct.error : data unpack requires a string argument of length 2
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/twisted/python/log.py",
line 84, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/twisted/python/log.py",
line 69, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/twisted/python/context.py",
line 59, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/twisted/python/context.py",
line 37, in callWithContext
return func(*args,**kw)
--- <exception caught here> ---
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/twisted/internet/selectreactor.py",
line 146, in _doReadOrWrite
why = getattr(selectable, method)()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/twisted/internet/tcp.py",
line 463, in doRead
return self.protocol.dataReceived(data)
File "/Users/gwik/Development/kwikeo/src/amqp/txamqp/protocol.py",
line 161, in dataReceived
frame, self.__buffer = self._unpackFrame(self.__buffer)
File "/Users/gwik/Development/kwikeo/src/amqp/txamqp/protocol.py",
line 133, in _unpackFrame
payload = Frame.DECODERS[frameType].decode(self.spec, c)
File "/Users/gwik/Development/kwikeo/src/amqp/txamqp/connection.py",
line 90, in decode
enc = dec.decode_longstr()
File "/Users/gwik/Development/kwikeo/src/amqp/txamqp/codec.py", line
154, in decode_longstr
return self.dec_str("!L")
File "/Users/gwik/Development/kwikeo/src/amqp/txamqp/codec.py", line
136, in dec_str
size = self.unpack(fmt)
File "/Users/gwik/Development/kwikeo/src/amqp/txamqp/codec.py", line
76, in unpack
values = unpack(fmt, data)
struct.error: unpack requires a string argument of length 4
I'm not sure how the error should be handled, maybe raising a
ValueError which is catched in FrameReceiver._unpackFrame would do the
job bu in fact i'm a python and amqp newcomer so I let this to you
guys ;)
I was able to reproduce the error on both python2.5 and 2.6. I'm on
mac os x tiger and txamqp is version 0.2.1 from tarball
I attached my source code and a modified version of txamqp that
re-raise the error.
run notifier.py for 10 seconds then launch observer.py
Best,
Antonin
Attachment:
txamp-bug.tgz
Description: GNU Zip compressed data
Follow ups