Skip to content

Commit e0b1de7

Browse files
committed
fail when is_pattern_topic is True and topics is a list
1 parent ed78ac5 commit e0b1de7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pulsar/asyncio.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,8 @@ async def subscribe(self, topic: Union[str, List[str]],
548548
default=ConsumerCryptoFailureAction.FAIL
549549
Set the behavior when the decryption fails.
550550
is_pattern_topic: bool, default=False
551-
Whether `topic` is a regex pattern. This option takes no effect
552-
when `topic` is a list of topics.
551+
Whether `topic` is a regex pattern. If it's True when `topic` is a list, a ValueError
552+
will be raised.
553553
554554
Returns
555555
-------
@@ -617,6 +617,12 @@ async def subscribe(self, topic: Union[str, List[str]],
617617
functools.partial(_set_future, future)
618618
)
619619
elif isinstance(topic, list):
620+
if is_pattern_topic:
621+
raise ValueError(
622+
"Argument 'topic' must be a string when "
623+
"'is_pattern_topic' is True; lists of topics do not "
624+
"support pattern subscriptions"
625+
)
620626
self._client.subscribe_async_topics(
621627
topic, subscription_name, conf,
622628
functools.partial(_set_future, future)

0 commit comments

Comments
 (0)