Skip to content

Commit 67eaa4a

Browse files
committed
fix: prevent warnings in online tests
1 parent e8aeebb commit 67eaa4a

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

freqtrade/exchange/exchange.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,17 +314,20 @@ def close(self):
314314
if self._exchange_ws:
315315
self._exchange_ws.cleanup()
316316
logger.debug("Exchange object destroyed, closing async loop")
317+
loop_running = self.loop.is_running() or asyncio.get_event_loop().is_running()
317318
if (
318319
getattr(self, "_api_async", None)
319320
and inspect.iscoroutinefunction(self._api_async.close)
320321
and self._api_async.session
322+
and not loop_running
321323
):
322324
logger.debug("Closing async ccxt session.")
323325
self.loop.run_until_complete(self._api_async.close())
324326
if (
325327
self._ws_async
326328
and inspect.iscoroutinefunction(self._ws_async.close)
327329
and self._ws_async.session
330+
and not loop_running
328331
):
329332
logger.debug("Closing ws ccxt session.")
330333
self.loop.run_until_complete(self._ws_async.close())

0 commit comments

Comments
 (0)