TypeError:使用rabbitmq发布时不可用的类型

时间:2016-06-24 11:57:52

标签: python python-2.7 rabbitmq

我试图通过pika将python字典传递给rabbitmq队列,这可能是一个python问题而不是rabbitmq本身。我收到如上所述的错误,这是我的代码:

def PingAddScan(deviceID, ipAddress, deviceHistory, item, date, apiURL, browserConId):
    if PingDevice(deviceID, ipAddress):
        BasicScan(ipAddress, deviceID, item, apiURL)
        deviceHistory[deviceID] = date

        # After the basic scan we are going to need to push a message back to the user to say
        # that the pathfinder has successfully found the device, and it should prompt the user
        # what he wants to scan
        print browserConId + " : " + deviceID
        channelOutbound.queue_declare(queue='outboundMessaging', durable=True)
        message = {"browserConnectionID": browserConId, "data": "FOUND", "deviceID": deviceID}
        print str(message)
        channelOutbound.basic_publish(exchange='messaging',
                              routing_key='outbound',
                              body=message)

这里是完整的堆栈跟踪:

    Traceback (most recent call last):
  File "pathfinderAllocator.py", line 454, in <module>
    channel.start_consuming()
  File "/usr/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 1755, in start_consuming
    self.connection.process_data_events(time_limit=None)
  File "/usr/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 715, in process_data_events
    self._dispatch_channel_events()
  File "/usr/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 518, in _dispatch_channel_events
    impl_channel._get_cookie()._dispatch_events()
  File "/usr/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 1384, in _dispatch_events
    evt.body)
  File "pathfinderAllocator.py", line 439, in callback
    PingAddScan(deviceID, ipAddress, deviceHistory, new_device, date, data, browser_connectionid)
  File "pathfinderAllocator.py", line 337, in PingAddScan
    body=message)
  File "/usr/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 2052, in basic_publish
    mandatory, immediate)
  File "/usr/local/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 2138, in publish
    immediate=immediate)
  File "/usr/local/lib/python2.7/site-packages/pika/channel.py", line 421, in basic_publish
    (properties, body))
  File "/usr/local/lib/python2.7/site-packages/pika/channel.py", line 1324, in _send_method
    self.connection._send_method(self.channel_number, method, content)
  File "/usr/local/lib/python2.7/site-packages/pika/connection.py", line 2137, in _send_method
    self._send_message(channel_number, method, content)
  File "/usr/local/lib/python2.7/site-packages/pika/connection.py", line 2164, in _send_message
    content[1][start:end]).marshal())
TypeError: unhashable type

0 个答案:

没有答案