Skip to content

Commit 08e1a61

Browse files
committed
feat: use unwatch to stop watching a websocket
1 parent 8009c03 commit 08e1a61

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

freqtrade/exchange/exchange_ws.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ async def _schedule_while_true(self) -> None:
138138
)
139139
)
140140

141+
async def _unwatch_ohlcv(self, pair: str, timeframe: str, candle_type: CandleType) -> None:
142+
try:
143+
await self.ccxt_object.un_watch_ohlcv_for_symbols([[pair, timeframe]])
144+
except ccxt.NotSupported as e:
145+
logger.debug("un_watch_ohlcv_for_symbols not supported: %s", e)
146+
pass
147+
141148
def _continuous_stopped(
142149
self, task: asyncio.Task, pair: str, timeframe: str, candle_type: CandleType
143150
):
@@ -150,6 +157,10 @@ def _continuous_stopped(
150157
result = str(result1)
151158

152159
logger.info(f"{pair}, {timeframe}, {candle_type} - Task finished - {result}")
160+
asyncio.run_coroutine_threadsafe(
161+
self._unwatch_ohlcv(pair, timeframe, candle_type), loop=self._loop
162+
)
163+
153164
self._klines_scheduled.discard((pair, timeframe, candle_type))
154165
self._pop_history((pair, timeframe, candle_type))
155166

0 commit comments

Comments
 (0)