Skip to content

Commit

Permalink
fix job remove
Browse files Browse the repository at this point in the history
  • Loading branch information
nlef committed Nov 11, 2024
1 parent fbac3c4 commit 97a058b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions bot/websocket_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,15 @@ async def run_forever_async(self):
try:
self._ws = websocket
self._scheduler.add_job(self.reshedule, "interval", seconds=2, id="ws_reschedule", replace_existing=True)
async for message in self._ws:
await self.websocket_to_message(message)
# async for message in self._ws:
# await self.websocket_to_message(message)

while True:
res = await self._ws.recv(decode=False)
await self.websocket_to_message(res)

except Exception as ex:
# Todo: add some TG notification?
logger.error(ex)
self._scheduler.remove_job("ws_reschedule")
if self._scheduler.get_job("ws_reschedule"):
self._scheduler.remove_job("ws_reschedule")
2 changes: 1 addition & 1 deletion scripts/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ psutil==6.1.0
python-telegram-bot[socks,http2,rate-limiter,callback-data,job-queue]==21.7
tzlocal==2.1
uvloop==0.20.0 ; platform_system != "Windows"
websockets==13.1
websockets==14.0

0 comments on commit 97a058b

Please sign in to comment.