PythonistaGuild / TwitchIO

An Async Bot/API wrapper for Twitch made in Python.
https://twitchio.dev
MIT License
791 stars 163 forks source link

fix: auto-reconnect websocket/bot #364

Closed TutorExilius closed 1 year ago

TutorExilius commented 1 year ago

Pull request summary

Twitch bot did not relogged automatically. The tasks which are created by asyncio.create_task() need to be collected to prevent task disappearing, see: https://docs.python.org/3/library/asyncio-task.html#creating-tasks

Important: Save a reference to the tasks, to avoid a task disappearing mid-execution.

Fixed disappearing of tasks by collecting and deleteing them within a defined cycle. With this fix, the websocket will reconnect automatically as intended.

Checklist

IAmTomahawkx commented 1 year ago

Hello, I'll review this in a bit once I get home. However a few meta things:

  1. Please run black over the affected files (make sure you use the -l120 flag) as it doesn't pass checks right now.
  2. Please update the changelog with a brief summary of changes made.
TutorExilius commented 1 year ago

Adapted changelog + blacked code (websocket.py)

IAmTomahawkx commented 1 year ago

youll need to revert ec0d9b1 and 1753a3b and rerun black with the -l120 flag, as running black on its own first has some unintended consequences

TutorExilius commented 1 year ago

Squashed two commits together (ec0d9b1 and 1753a3b blacked code) and force pushed.

TutorExilius commented 1 year ago

what is the status? when can we expect the fix? :) @IAmTomahawkx @EvieePy

chillymosh commented 1 year ago

LGTM but will wait for @EvieePy to approve this one