From 2b448d87c623333ab2f70e5e0ccad39249fdffca Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Thu, 2 Nov 2023 13:47:31 +0000 Subject: [PATCH] Fixed subscribe topic bug --- CHANGELOG.rst | 6 ++++++ brewtils/decorators.py | 16 +++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 645f5faf..3f7ceb43 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ Brewtils Changelog ================== +3.20.1 +------ +TBD + +- Fixed an issue where topics could repeat when using topic in @subscribe + 3.20.0 ------ 11/1/2023 diff --git a/brewtils/decorators.py b/brewtils/decorators.py index 9ccceb00..954ea1c8 100644 --- a/brewtils/decorators.py +++ b/brewtils/decorators.py @@ -399,17 +399,23 @@ def returnTrue(self): topics: A list of topics to subscribe to """ - if topic: - topics.append(topic) + subscribe_topics = [] + if topic and topic not in subscribe_topics: + subscribe_topics.append(topic) + + if topics: + for list_topic in topics: + if list_topic not in subscribe_topics: + subscribe_topics.append(list_topic) if _wrapped is None: - return functools.partial(subscribe, topics=topics) + return functools.partial(subscribe, topics=subscribe_topics) # Python 2 compatibility if hasattr(_wrapped, "__func__"): - _wrapped.__func__.subscribe_topics = topics + _wrapped.__func__.subscribe_topics = subscribe_topics else: - _wrapped.subscribe_topics = topics + _wrapped.subscribe_topics = subscribe_topics return _wrapped