#Task only executes twice

1 messages · Page 1 of 1 (latest)

unkempt epoch
#

Good evening! I have a task that runs a couple of times and then never runs again. I don't get any errors or anything from it. Could I get some help figuring out why it's erroring?

class Response(commands.Cog):

    def __init__(self, bot: BotClient):
        self.bot: BotClient = bot
        self.log: logging.Logger = logging.getLogger(f"{self.bot.settings.log_name}.{self.__class__.__name__}")

        self.response_update.start()
        self.server_display_update.start()

    @tasks.loop(seconds=30.0)
    async def server_display_update(self):
        records = await crud.get_api_response(self.bot.pool)
        self.log.debug(f"Response update: Player: {records.player_resp}ms "
                       f"Clan: {records.clan_resp}ms War: {records.war_resp}ms")

        for key_name in records.__dict__.keys():
            channel = self.bot.get_channel(self.bot.settings.get_channel(key_name))
            if channel is None:
                self.log.error(f"Could not find channel {key_name}")
                continue

            channel_name = " ".join(key_name.split("_")).title()
            await channel.edit(name=f"{channel_name}: {records.__dict__.get(key_name)}ms")

    @tasks.loop(seconds=15.0)
    async def response_update(self) -> None:
        loop = asyncio.get_event_loop()
        player_resp, clan_resp, war_resp = await loop.run_in_executor(
            None, self.get_response_times)

        await crud.set_api_response(self.bot.pool, player_resp, clan_resp, war_resp)

    @server_display_update.before_loop
    @response_update.before_loop
    async def before_loops(self):
        await self.bot.wait_until_ready()

    def cog_unload(self):
        self.response_update.cancel()
        self.server_display_update.cancel()
#

wtf I just randomly got it to fire a couple more times. The heck is going on

gilded blade
#

which task?

unkempt epoch
gilded blade
#

to start i would just add a print statement at the top of the loop

#

to see if its not actually firining or its getting lost somewhere in between

#

also ur before loop

unkempt epoch
#

Looks like I was hitting the rate limit for channel name changes. it

#

it's fixed! thanks