Improve "stopped" messages

This commit is contained in:
Matthias
2024-04-19 18:27:47 +02:00
parent 85725b5472
commit fc66a12c14
+5 -2
View File
@@ -2,6 +2,7 @@
import asyncio import asyncio
import logging import logging
import time import time
from functools import partial
from threading import Thread from threading import Thread
from typing import Dict, Set from typing import Dict, Set
@@ -88,9 +89,11 @@ class ExchangeWS:
task = asyncio.create_task( task = asyncio.create_task(
self._continuously_async_watch_ohlcv(pair, timeframe, candle_type)) self._continuously_async_watch_ohlcv(pair, timeframe, candle_type))
self._background_tasks.add(task) self._background_tasks.add(task)
task.add_done_callback(self._continuous_stopped) task.add_done_callback(partial(
self._continuous_stopped, pair=pair, timeframe=timeframe)
)
def _continuous_stopped(self, task: asyncio.Task): def _continuous_stopped(self, task: asyncio.Task, pair: str, timeframe: str):
self._background_tasks.discard(task) self._background_tasks.discard(task)
result = task.result() result = task.result()
logger.info(f"Task finished {result}") logger.info(f"Task finished {result}")