diff options
author | Omer Katz <omer.drow@gmail.com> | 2019-04-04 12:28:48 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-04 12:28:48 +0300 |
commit | ba87c167931c93fd09f21a017390753a108503a1 (patch) | |
tree | 2e2de4b11eeab7f73fdacaf11757c3e709af3bc9 | |
parent | 57f464895dfdf7bbf2b4eafbe180d09c51bb889e (diff) | |
download | kombu-librabbitmq-transport-priority-fix.tar.gz |
Include priority in properties only if it's not None.librabbitmq-transport-priority-fix
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.
-rw-r--r-- | kombu/transport/librabbitmq.py | 8 |
1 files 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): |