ebin123456 / py-amqplib

Automatically exported from code.google.com/p/py-amqplib
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Missing support for sequence serialization #38

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm enclosing a patch both in plain and in hg bundle format, which adds:

1. UnitTests for sequence serialization/deserialization
2. Sequence serialization/deserialization support

While under 1.0 amqplib raises a sensible exception while trying to
publish a message whose application headers contain a sequence:

>>> from  amqplib import client_0_8 as amqp
>>> cn=amqp.Connection(userid='test', password='*********', 
virtual_host='*******')
>>> ch=cn.channel()
>>> msg = amqp.Message('hello world', application_headers = 
{'hdr1':['val1','val2']})
>>> ch.basic_publish(msg,routing_key='tests', exchange='hdrXc')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "amqplib/client_0_8/channel.py", line 2310, in basic_publish
    self._send_method((60, 40), args, msg)
  File "amqplib/client_0_8/abstract_channel.py", line 76, in _send_method
    method_sig, args, content)
  File "amqplib/client_0_8/method_framing.py", line 250, in write_method
    properties = content._serialize_properties()
  File "amqplib/client_0_8/serialization.py", line 531, in _serialize_properties
    getattr(raw_bytes, 'write_' + proptype)(val)
  File "amqplib/client_0_8/serialization.py", line 397, in write_table
    raise ValueError('%s not serializable in AMQP' % repr(v))
ValueError: ['val1', 'val2'] not serializable in AMQP

in the 0.6.1 case the ch.basic_publish seems to return, but  on subsequent 
publish() tries I get a socket error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.6/amqplib/client_0_8/channel.py", line 2223, in basic_publish
    self._send_method((60, 40), args, msg)
  File "/usr/lib/pymodules/python2.6/amqplib/client_0_8/abstract_channel.py", line 70, in _send_method
    method_sig, args, content)
  File "/usr/lib/pymodules/python2.6/amqplib/client_0_8/method_framing.py", line 240, in write_method
    self.dest.write_frame(2, channel, payload)
  File "/usr/lib/pymodules/python2.6/amqplib/client_0_8/transport.py", line 125, in write_frame
    frame_type, channel, size, payload, 0xce))
  File "<string>", line 1, in sendall
socket.error: [Errno 32] Broken pipe

Original issue reported on code.google.com by lmcatu...@gmail.com on 12 Sep 2011 at 1:25

Attachments:

GoogleCodeExporter commented 9 years ago
I haven't seen sequences mentioned in the 0-8 specs, is it a 0-9ism?  Can you 
point to some docs?

Original comment by barry.pe...@gmail.com on 28 Sep 2011 at 10:29

GoogleCodeExporter commented 9 years ago
+1 for this patch.

We're experiencing the same exception on taks with *args, **kwargs. The 
attached patch has worked flawlessly for us in production at 
universalsubtitles.org.

Original comment by debert on 25 Oct 2011 at 3:00

GoogleCodeExporter commented 9 years ago
Sorry for not following-up in a timely manner.
I must confirm the sequence syntax is 0.9.1 stuff.

Since the differences between 0.8 and 0.9 are really limited,
I'm unsure they warrant the creation of a client_0.9 being mostly
equal to 0.8, save some added datatypes.

Thank you very much.

Original comment by lmcatu...@gmail.com on 25 Oct 2011 at 4:40