From c1b1010daa6c8cee35230ce2f73b3f2c3bb7b10b Mon Sep 17 00:00:00 2001 From: Omer Katz Date: Wed, 22 May 2019 12:25:52 +0300 Subject: [PATCH] Include priority in properties only if it's not None. (#1038) Since we attempt to serialize the priority property if it exists in the dictionary (See https://github.com/celery/librabbitmq/blob/3fa1d38c4e66e6efdbdc7d584abe0a59857bef29/Modules/_librabbitmq/connection.c#L739) it must be an integer. Fixes celery/celery#5340. --- kombu/transport/librabbitmq.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kombu/transport/librabbitmq.py b/kombu/transport/librabbitmq.py index 18c1dd1f..4fc9cc99 100644 --- a/kombu/transport/librabbitmq.py +++ b/kombu/transport/librabbitmq.py @@ -57,8 +57,12 @@ class Channel(amqp.Channel, base.StdChannel): properties = properties if properties is not None else {} properties.update({'content_type': content_type, 'content_encoding': content_encoding, - 'headers': headers, - 'priority': priority}) + 'headers': headers}) + # Don't include priority if it's not an integer. + # If that's the case librabbitmq will fail + # and raise an exception. + if priority is not None: + properties['priority'] = priority return body, properties def prepare_queue_arguments(self, arguments, **kwargs):