Fix exception on exchange shutdown

This commit is contained in:
Matthias 2021-12-31 11:21:02 +01:00
parent 78ccaae318
commit 39f8c5719b
2 changed files with 4 additions and 1 deletions

View File

@ -170,7 +170,9 @@ class Exchange:
def close(self): def close(self):
logger.debug("Exchange object destroyed, closing async loop") logger.debug("Exchange object destroyed, closing async loop")
if self._api_async and inspect.iscoroutinefunction(self._api_async.close): if (self._api_async and inspect.iscoroutinefunction(self._api_async.close)
and self._api_async.session):
logger.info("Closing async ccxt session.")
asyncio.get_event_loop().run_until_complete(self._api_async.close()) asyncio.get_event_loop().run_until_complete(self._api_async.close())
def _init_ccxt(self, exchange_config: Dict[str, Any], ccxt_module: CcxtModuleType = ccxt, def _init_ccxt(self, exchange_config: Dict[str, Any], ccxt_module: CcxtModuleType = ccxt,

View File

@ -126,6 +126,7 @@ class FreqtradeBot(LoggingMixin):
self.rpc.cleanup() self.rpc.cleanup()
cleanup_db() cleanup_db()
self.exchange.close()
def startup(self) -> None: def startup(self) -> None:
""" """