Skip to content

Commit

Permalink
Fix custom headers propagation for protocol 1 hybrid messages
Browse files Browse the repository at this point in the history
  • Loading branch information
beezz committed Sep 29, 2020
1 parent ea37db1 commit 14e5a84
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions celery/worker/strategy.py
Expand Up @@ -50,6 +50,7 @@ def hybrid_to_proto2(message, body):
'kwargsrepr': body.get('kwargsrepr'),
'origin': body.get('origin'),
}
headers.update(message.headers or {})

embed = {
'callbacks': body.get('callbacks'),
Expand Down
6 changes: 5 additions & 1 deletion t/unit/worker/test_strategy.py
Expand Up @@ -271,7 +271,7 @@ def failed():
class test_hybrid_to_proto2:

def setup(self):
self.message = Mock(name='message')
self.message = Mock(name='message', headers={"custom": "header"})
self.body = {
'args': (1,),
'kwargs': {'foo': 'baz'},
Expand All @@ -288,3 +288,7 @@ def test_retries_custom_value(self):
self.body['retries'] = _custom_value
_, headers, _, _ = hybrid_to_proto2(self.message, self.body)
assert headers.get('retries') == _custom_value

def test_custom_headers(self):
_, headers, _, _ = hybrid_to_proto2(self.message, self.body)
assert headers.get("custom") == "header"

0 comments on commit 14e5a84

Please sign in to comment.