Skip to content

Commit 0605371

Browse files
author
Shlomi Kushchi
authored
Merge pull request #272 from alpacahq/a_bit_more_verbose
A bit more verbose ws connection
2 parents 257cbbf + 0c609c8 commit 0605371

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

alpaca_trade_api/polygon/streamconn.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ async def connect(self):
4343
.format(msg))
4444
)
4545
await self._dispatch(msg)
46+
logging.info(f"connected to: {self._endpoint}")
4647
if await self.authenticate():
4748
self._consume_task = asyncio.ensure_future(self._consume_msg())
4849
else:

alpaca_trade_api/stream2.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import json
33
import os
44
import re
5+
from asyncio import CancelledError
6+
57
import websockets
68
from .common import get_base_url, get_data_url, get_credentials, URL
79
from .entity import Account, Entity, trade_mapping, agg_mapping, quote_mapping
@@ -57,7 +59,7 @@ async def _connect(self):
5759

5860
self._ws = ws
5961
await self._dispatch('authorized', msg)
60-
62+
logging.info(f"connected to: {self._endpoint}")
6163
self._consume_task = asyncio.ensure_future(self._consume_msg())
6264

6365
async def consume(self):
@@ -289,7 +291,8 @@ def run(self, initial_channels: List[str] = []):
289291
logging.info("Exiting on Interrupt")
290292
should_renew = False
291293
except Exception as e:
292-
logging.error(f"error while consuming ws messages: {e}")
294+
m = 'consume cancelled' if isinstance(e, CancelledError) else e
295+
logging.error(f"error while consuming ws messages: {m}")
293296
loop.run_until_complete(self.close(should_renew))
294297
if loop.is_running():
295298
loop.close()

0 commit comments

Comments
 (0)