Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

struct Type Error when consume internal log message. #609

Closed
barryz opened this issue Jul 11, 2016 · 2 comments
Closed

struct Type Error when consume internal log message. #609

barryz opened this issue Jul 11, 2016 · 2 comments

Comments

@barryz
Copy link

barryz commented Jul 11, 2016

my demo code:

from kombu import Exchange, Queue
from kombu.mixins import ConsumerMixin
from kombu import Connection


task_exchange = Exchange(name="amq.rabbitmq.log", type="topic")
task_queues = [Queue(exchange=task_exchange, routing_key='error.#', exclusive=True, auto_delete=True)]


class Worker(ConsumerMixin):

    def __init__(self, connection):
        self.connection = connection

    def get_consumers(self, Consumer, channel):
        return [Consumer(queues=task_queues,
                         # accept=['pickle', 'json'],
                         callbacks=[self.process_task])]

    def process_task(self, body, message):
        print(body)
        message.ack()

if __name__ == '__main__':
    with Connection('amqp://admin:admin@local.elenet.me:5672//') as conn:
        try:
            worker = Worker(conn)
            worker.run()
        except KeyboardInterrupt:
            print('bye bye')

then catch an exception:

File "/usr/lib/python2.7/site-packages/amqp-2.0.2-py2.7.egg/amqp/connection.py", line 440, in blocking_read
    frame = self.transport.read_frame()
  File "/usr/lib/python2.7/site-packages/amqp-2.0.2-py2.7.egg/amqp/transport.py", line 235, in read_frame
    frame_type, channel, size = unpack('>BHI', frame_header)
TypeError: Struct() argument 1 must be string, not unicode

After I change this code, it works well.

# frame_type, channel, size = unpack('>BHI', frame_header)
frame_type, channel, size = unpack(str('>BHI'), frame_header)
@ask
Copy link
Contributor

ask commented Jul 12, 2016

What Python version is this?

@barryz
Copy link
Author

barryz commented Jul 25, 2016

python 2.7.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants