Skip to content

Commit

Permalink
revert to original changes
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfMissingNo committed Sep 30, 2021
1 parent a802afc commit f3c281b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions alpaca_trade_api/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ async def _start_ws(self):
log.info(f'connected to: {self._endpoint}')

async def close(self):
self._run_forever_flag = False
if self._ws:
await self._ws.close()
self._ws = None
self._running = False
self._run_forever_flag = False

async def stop_ws(self):
self._stop_stream_queue.put_nowait({"should_stop": True})
Expand Down Expand Up @@ -467,11 +467,11 @@ async def _run_forever(self):
await asyncio.sleep(0.01)

async def close(self):
self._run_forever_flag = False
if self._ws:
await self._ws.close()
self._ws = None
self._running = False
self._run_forever_flag = False

async def stop_ws(self):
self._stop_stream_queue.put_nowait({"should_stop": True})
Expand Down Expand Up @@ -655,9 +655,12 @@ def run(self):
pass

async def _close(self):
await self._trading_ws.close()
await self._data_ws.close()
await self._crypto_ws.close()
await asyncio.gather(
self.stop_ws(),
self._trading_ws.close(),
self._data_ws.close(),
self._crypto_ws.close()
)

def close(self):
loop = asyncio.get_event_loop()
Expand Down

0 comments on commit f3c281b

Please sign in to comment.