Convert status_task to nextcord ext.tasks.loop - #50
Merged
Conversation
Replace the hand-rolled presence loop (a while-not-is_closed() loop started via bot.loop.create_task in __init__) with the modern @tasks.loop(seconds=15) helper. The toggle state moves from a loop-local to self._display_streams, the one-time startup work (wait_until_ready, Tautulli init, version logging) moves to a @before_loop hook, and cog_unload cancels the loop instead of a tracked task handle. The per-iteration try/except is kept so a Tautulli hiccup logs and the loop keeps ticking, matching the old resilience. This removes the fragile bot.loop.create_task(self.initialize()) in __init__ and the manual asyncio.sleep pacing. On shutdown the loop is cancelled cleanly: commands.Bot.close() unloads cogs (firing cog_unload) before the gateway and the shared Tautulli session close. Updated the PlexBot.close() docstring to describe that mechanism. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the hand-rolled presence loop (
while not self.bot.is_closed()started viabot.loop.create_task(self.initialize())in__init__) with the modern@tasks.loop(seconds=15)helper.self._display_streams.wait_until_ready→ Tautulli init → version logging) moves to a@before_loophook.cog_unloadcancels the loop; the per-iterationtry/exceptis kept so a Tautulli hiccup logs and the loop keeps ticking.commands.Bot.close()unloads cogs (firingcog_unload) before the gateway and the shared Tautulli session close. Updated thePlexBot.close()docstring to describe that.Verification:
ruffclean, 30/30 tests pass, runtime smoke test (loop start → before_loop init → tick sets presence → toggle flips →cog_unloadcancels).🤖 Generated with Claude Code