Skip to content

Commit 05e759a

Browse files
committed
fix: check if loop exists
avoids errors if exchange init shuts down before the loop is created closes freqtrade#12822
1 parent 67eaa4a commit 05e759a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

freqtrade/exchange/exchange.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,10 @@ 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()
317+
loop_running = (
318+
hasattr(self, "loop") and self.loop.is_running()
319+
) or asyncio.get_event_loop().is_running()
320+
318321
if (
319322
getattr(self, "_api_async", None)
320323
and inspect.iscoroutinefunction(self._api_async.close)

0 commit comments

Comments
 (0)