dfaulken / iRacing-team-balance-bot

Monitors the iRating of team members to find the optimal grouping of drivers into teams with balanced average iRating.
MIT License
1 stars 1 forks source link

Need better exception handling of iRacing client #2

Open dfaulken opened 3 years ago

dfaulken commented 3 years ago

Experienced some weird timeouts today, and there is the lingering issue with the driver_stats endpoint. Bot should handle these more gracefully than simply failing.

dfaulken commented 3 years ago

This is high priority now. Overnight the bot's connection with the API timed out during a background recheck, which completely froze the bot.

[2021-01-27 11:25:47,695 WARNING]:Shard ID None heartbeat blocked for more than 26120 seconds.
Loop thread traceback (most recent call last):
  File "/home/deploy/iRacing-team-balance-bot/main.py", line 927, in <module>
    di_client.run(os.getenv('TOKEN'))
  File "/home/deploy/.local/lib/python3.8/site-packages/discord/client.py", line 708, in run
    loop.run_forever()
  File "/usr/lib/python3.8/asyncio/base_events.py", line 570, in run_forever
    self._run_once()
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1859, in _run_once
    handle._run()
  File "/usr/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "/home/deploy/.local/lib/python3.8/site-packages/periodic/periodic.py", line 158, in __runner
    await self.__coro(*self.__args, **self.__kwargs)
  File "/home/deploy/iRacing-team-balance-bot/main.py", line 406, in background_recheck
    for guild_id in guild_ids():
  File "/home/deploy/iRacing-team-balance-bot/main.py", line 67, in guild_ids
    return [file.name for file in os.scandir('data') if file.is_dir()]
  File "/usr/lib/python3.8/bdb.py", line 88, in trace_dispatch
    return self.dispatch_line(frame)
  File "/usr/lib/python3.8/bdb.py", line 112, in dispatch_line
    self.user_line(frame)
  File "/usr/lib/python3.8/pdb.py", line 262, in user_line
    self.interaction(frame, None)
  File "/usr/lib/python3.8/pdb.py", line 357, in interaction
    self._cmdloop()
  File "/usr/lib/python3.8/pdb.py", line 322, in _cmdloop
    self.cmdloop()
  File "/usr/lib/python3.8/cmd.py", line 126, in cmdloop
    line = input(self.prompt)

I'm confused why the issue manifested at that particular line of the background recheck job, but I'm going with the "where's there's smoke" approach given the warning directly above the exception.

dfaulken commented 3 years ago

Actually may have been due to a rogue pdb.set_trace() left in the code.