Skip to content

Commit f3c281b

Browse files
committed
revert to original changes
1 parent a802afc commit f3c281b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

alpaca_trade_api/stream.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ async def _start_ws(self):
7676
log.info(f'connected to: {self._endpoint}')
7777

7878
async def close(self):
79-
self._run_forever_flag = False
8079
if self._ws:
8180
await self._ws.close()
8281
self._ws = None
8382
self._running = False
83+
self._run_forever_flag = False
8484

8585
async def stop_ws(self):
8686
self._stop_stream_queue.put_nowait({"should_stop": True})
@@ -467,11 +467,11 @@ async def _run_forever(self):
467467
await asyncio.sleep(0.01)
468468

469469
async def close(self):
470-
self._run_forever_flag = False
471470
if self._ws:
472471
await self._ws.close()
473472
self._ws = None
474473
self._running = False
474+
self._run_forever_flag = False
475475

476476
async def stop_ws(self):
477477
self._stop_stream_queue.put_nowait({"should_stop": True})
@@ -655,9 +655,12 @@ def run(self):
655655
pass
656656

657657
async def _close(self):
658-
await self._trading_ws.close()
659-
await self._data_ws.close()
660-
await self._crypto_ws.close()
658+
await asyncio.gather(
659+
self.stop_ws(),
660+
self._trading_ws.close(),
661+
self._data_ws.close(),
662+
self._crypto_ws.close()
663+
)
661664

662665
def close(self):
663666
loop = asyncio.get_event_loop()

0 commit comments

Comments
 (0)