Using alpaca_trade_api python client, am subscribing to crypto & stock stream data. In python, flask environment on re/start, my stream subscription via the alpaca_trade_api stream client goes into a loop forever…
RuntimeError should be caught in this loop and graceful exit and restart should occur. Looks like a bug.
-sj
--------- trace ----
RuntimeError: cannot schedule new futures after shutdown
starting crypto data websocket connection
error during websocket communication: cannot schedule new futures after shutdown
Traceback (most recent call last):
File “/Users/sj/opt/anaconda3/lib/python3.8/site-packages/alpaca_trade_api/stream.py”, line 215, in _run_forever
await self._start_ws()
File “/Users/sj/opt/anaconda3/lib/python3.8/site-packages/alpaca_trade_api/stream.py”, line 74, in _start_ws
await self._connect()
File “/Users/sj/opt/anaconda3/lib/python3.8/site-packages/alpaca_trade_api/stream.py”, line 51, in _connect
self._ws = await websockets.connect(
File “/Users/sj/opt/anaconda3/lib/python3.8/site-packages/websockets/client.py”, line 535, in await_impl
transport, protocol = await self._create_connection()
File “/Users/sj/opt/anaconda3/lib/python3.8/asyncio/base_events.py”, line 986, in create_connection
infos = await self._ensure_resolved(
File “/Users/sj/opt/anaconda3/lib/python3.8/asyncio/base_events.py”, line 1365, in _ensure_resolved
return await loop.getaddrinfo(host, port, family=family, type=type,
File “/Users/sj/opt/anaconda3/lib/python3.8/asyncio/base_events.py”, line 825, in getaddrinfo
return await self.run_in_executor(
File “/Users/sj/opt/anaconda3/lib/python3.8/asyncio/base_events.py”, line 783, in run_in_executor
executor.submit(func, *args), loop=self)
File “/Users/sj/opt/anaconda3/lib/python3.8/concurrent/futures/thread.py”, line 179, in submit
raise RuntimeError(‘cannot schedule new futures after shutdown’)
RuntimeError: cannot schedule new futures after shutdown
starting crypto data websocket connection
error during websocket communication: cannot schedule new futures after shutdown
Traceback (most recent call last):
File “/Users/sj/opt/anaconda3/lib/python3.8/site-packages/alpaca_trade_api/stream.py”, line 215, in _run_forever
await self._start_ws()
File “/Users/sj/opt/anaconda3/lib/python3.8/site-packages/alpaca_trade_api/stream.py”, line 74, in _start_ws
await self._connect()
File “/Users/sj/opt/anaconda3/lib/python3.8/site-packages/alpaca_trade_api/stream.py”, line 51, in _connect
self._ws = await websockets.connect(
File “/Users/sj/opt/anaconda3/lib/python3.8/site-packages/websockets/client.py”, line 535, in await_impl
transport, protocol = await self._create_connection()
File “/Users/sj/opt/anaconda3/lib/python3.8/asyncio/base_events.py”, line 986, in create_connection
infos = await self._ensure_resolved(
File “/Users/sj/opt/anaconda3/lib/python3.8/asyncio/base_events.py”, line 1365, in _ensure_resolved
return await loop.getaddrinfo(host, port, family=family, type=type,
File “/Users/sj/opt/anaconda3/lib/python3.8/asyncio/base_events.py”, line 825, in getaddrinfo
return await self.run_in_executor(
File “/Users/sj/opt/anaconda3/lib/python3.8/asyncio/base_events.py”, line 783, in run_in_executor
executor.submit(func, *args), loop=self)
File “/Users/sj/opt/anaconda3/lib/python3.8/concurrent/futures/thread.py”, line 179, in submit
raise RuntimeError(‘cannot schedule new futures after shutdown’)
RuntimeError: cannot schedule new futures after shutdown