Skip to content

Commit a7e23c6

Browse files
authored
Only call the news handler once for a single message (#693)
1 parent 5c2d74a commit a7e23c6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

alpaca_trade_api/stream.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,8 @@ async def _dispatch(self, msg):
567567
msg_type = msg.get('T')
568568
if msg_type == 'n':
569569
symbols = msg.get('symbols', [])
570-
# A news article could be unrelated to any symbols, resulting in an empty symbols list. Those news articles
570+
# A news article could be unrelated to any symbols,
571+
# resulting in an empty symbols list. Those news articles
571572
# should still be dispatched to the wildcard event handler.
572573
if not symbols:
573574
symbols.append('*')
@@ -579,6 +580,8 @@ async def _dispatch(self, msg):
579580

580581
if handler is not None:
581582
await handler(self._cast(msg_type, msg))
583+
# For a single message, only call the handler once
584+
break
582585
else:
583586
await super()._dispatch(msg)
584587

0 commit comments

Comments
 (0)