Skip to content

Start scan loop on startup#136

Merged
Robin5605 merged 3 commits intomainfrom
task-on-startup
Jul 22, 2023
Merged

Start scan loop on startup#136
Robin5605 merged 3 commits intomainfrom
task-on-startup

Conversation

@Robin5605
Copy link
Member

@Robin5605 Robin5605 commented Jul 22, 2023

Closes #127
Starts the Dragonfly task in charge of posting scan results on bot startup

Copy link
Member

@import-pandas-as-numpy import-pandas-as-numpy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. before_loop required some googling to make sure you weren't making up random crap.

async def setup(bot: Bot) -> None:
await bot.add_cog(Dragonfly(bot))
cog = Dragonfly(bot)
cog.scan_loop.start()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this cause a RuntimeError if the extension is reloaded?

Robin5605 and others added 3 commits July 22, 2023 13:17
Move the scan loop task's startup code into the cog's `setup()` method
because it makes more sense to do it there and also simultaneously
avoids circular imports. Also avoids cluttering the "global"
`setup_hook` of the bot with any other auto-start tasks we might need in
the future.
Signed-off-by: Robin <74519799+Robin5605@users.noreply.github.com>
@Robin5605 Robin5605 merged commit 0119eca into main Jul 22, 2023
@Robin5605 Robin5605 deleted the task-on-startup branch July 22, 2023 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Start task on bot startup

3 participants