INNER CODE UNIT · Python
unsubscribe
permitio/fastapi_websocket_pubsub · fastapi_websocket_pubsub/event_notifier.py:139
async def unsubscribe(
self, subscriber_id: SubscriberId, topics: Union[TopicList, None] = None
):
"""
Unsubscribe from given topics.
Pass topics=None to unsubscribe the given subscriber from all topics
Args:
subscriber_id (SubscriberID): A UUID identifying the subscriber
topics (Union[TopicList, None]): Topics to unsubscribe from
"""
async with self._get_subscribers_lock():
# if no topics are given then unsubscribe from all topics
if topics is None:
topics = list(self._topics.keys())
for topic in topics:
subscribers = self._topics[topic]
if subscriber_id in subscribers: