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 3fa1d38c4e/Modules/_librabbitmq/connection.c (L739)) it must be an integer.

Fixes celery/celery#5340.
This commit is contained in:
Omer Katz 2019-05-22 12:25:52 +03:00 committed by Asif Saif Uddin
parent 57d2ec8b65
commit c1b1010daa
1 changed files with 6 additions and 2 deletions

View File

@ -57,8 +57,12 @@ class Channel(amqp.Channel, base.StdChannel):
properties = properties if properties is not None else {} properties = properties if properties is not None else {}
properties.update({'content_type': content_type, properties.update({'content_type': content_type,
'content_encoding': content_encoding, 'content_encoding': content_encoding,
'headers': headers, 'headers': headers})
'priority': priority}) # 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 return body, properties
def prepare_queue_arguments(self, arguments, **kwargs): def prepare_queue_arguments(self, arguments, **kwargs):