diff options
author | KUAN Hsuan-Tso <kst920106@gmail.com> | 2018-08-15 18:59:33 +0800 |
---|---|---|
committer | Asif Saifuddin Auvi <auvipy@gmail.com> | 2018-08-15 16:59:33 +0600 |
commit | 87d6423289caa776fc10a8d7cdb3d4b741460cfa (patch) | |
tree | dd0bee25786dce37517079122051a666a75f4b2b | |
parent | 1160b92c27f2f6c56554663f0d6d4ad9194b3dff (diff) | |
download | kombu-87d6423289caa776fc10a8d7cdb3d4b741460cfa.tar.gz |
fix/Broadcast-fail-by-give-queue-kwargs (#906)
* If give queue kwargs broadcast will fail
Because give Broadcast(name='xxx', queue='xxx'),
it will create one specific name for queue,
and if launch more worker for consuming this queue,
this specific name queue already exist then it will not create new queue to
binding fanout exchange.
So all worker will consuming same queue, and exchange only binding this
queue then lose the effect of broadcasting.
* modify test_Broadcast
-rw-r--r-- | kombu/common.py | 2 | ||||
-rw-r--r-- | t/unit/test_common.py | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/kombu/common.py b/kombu/common.py index 47d2a59d..d5d4e0dc 100644 --- a/kombu/common.py +++ b/kombu/common.py @@ -87,7 +87,7 @@ class Broadcast(Queue): def __init__(self, name=None, queue=None, auto_delete=True, exchange=None, alias=None, **kwargs): - queue = queue or 'bcast.{0}'.format(uuid()) + queue = '{0}.{1}'.format(queue or 'bcast', uuid()) return super(Broadcast, self).__init__( alias=alias or name, queue=queue, diff --git a/t/unit/test_common.py b/t/unit/test_common.py index 9cc30d15..a7241613 100644 --- a/t/unit/test_common.py +++ b/t/unit/test_common.py @@ -80,11 +80,11 @@ class test_Broadcast: assert q.exchange.type == 'fanout' q = Broadcast('test_Broadcast', 'explicit_queue_name') - assert q.name == 'explicit_queue_name' + assert q.name.startswith('explicit_queue_name.') assert q.exchange.name == 'test_Broadcast' q2 = q(Mock()) - assert q2.name == q.name + assert q2.name.split('.')[0] == q.name.split('.')[0] class test_maybe_declare: |