Skip to content

Commit 6daa73c

Browse files
committed
EventNotifier: Add TODO for avoiding duplicate updates
1 parent c3376a8 commit 6daa73c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fastapi_websocket_pubsub/event_notifier.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,10 @@ async def notify(
255255
# TODO improve with reader/writer lock pattern - so multiple notifications can happen at once
256256
async with self._get_subscribers_lock():
257257
for topic in topics:
258+
# TODO: Multiple topics can have the same subscriber - we should first aggregate the entire list of subscribers for all topics,
259+
# and only then create the `callbacks` list so each subscriber is called only once (to avoid duplicated updates)
258260
subscribers = self._topics.get(topic, {})
261+
259262
# handle direct topic subscribers (work on copy to avoid changes after we got the callbacks running)
260263
callbacks.append(
261264
self.callback_subscribers(

0 commit comments

Comments
 (0)