Skip to content

Commit a802afc

Browse files
committed
fixing close
1 parent b9ace48 commit a802afc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

alpaca_trade_api/stream.py

Lines changed: 2 additions & 2 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
7980
if self._ws:
8081
await self._ws.close()
8182
self._ws = None
8283
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
470471
if self._ws:
471472
await self._ws.close()
472473
self._ws = None
473474
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})

0 commit comments

Comments
 (0)