Extract close method for exchange
This commit is contained in:
parent
4ce4eadc23
commit
b5177eadab
@ -147,6 +147,9 @@ class Exchange:
|
||||
"""
|
||||
Destructor - clean up async stuff
|
||||
"""
|
||||
self.close()
|
||||
|
||||
def close(self):
|
||||
logger.debug("Exchange object destroyed, closing async loop")
|
||||
if self._api_async and inspect.iscoroutinefunction(self._api_async.close):
|
||||
asyncio.get_event_loop().run_until_complete(self._api_async.close())
|
||||
|
@ -661,6 +661,7 @@ class Hyperopt:
|
||||
dump(preprocessed, self.data_pickle_file)
|
||||
|
||||
# We don't need exchange instance anymore while running hyperopt
|
||||
self.backtesting.exchange.close()
|
||||
self.backtesting.exchange._api = None # type: ignore
|
||||
self.backtesting.exchange._api_async = None # type: ignore
|
||||
# self.backtesting.exchange = None # type: ignore
|
||||
|
Loading…
Reference in New Issue
Block a user