Skip to content

Commit bbc1749

Browse files
committed
Address PR comments
1 parent baed24d commit bbc1749

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

publish_subscribe.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ def notify(self, msg):
1717
self.msg_queue.append(msg)
1818

1919
def subscribe(self, msg, subscriber):
20-
if msg not in self.subscribers:
21-
self.subscribers[msg] = []
22-
23-
self.subscribers[msg].append(subscriber)
20+
self.subscribers.setdefault(msg, []).append(subscriber)
2421

2522
def unsubscribe(self, msg, subscriber):
2623
self.subscribers[msg].remove(subscriber)

0 commit comments

Comments
 (0)