#my bot will randomly have errors when running commands RuntimeError: coroutine ignored GeneratorExit

1 messages · Page 1 of 1 (latest)

hardy coral
#
Traceback (most recent call last):
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\interactions\client\client.py", line 1900, in __dispatch_interaction
    response = await callback
               ^^^^^^^^^^^^^^
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\interactions\client\client.py", line 1771, in _run_slash_command
    return await command(ctx, **ctx.kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\interactions\models\internal\command.py", line 132, in __call__
    await self.call_callback(self.callback, context)
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\interactions\models\internal\application_commands.py", line 833, in call_callback
    return await self.call_with_binding(callback, ctx, *new_args, **new_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Gamer\AppData\Local\Programs\Python\Python311\Lib\site-packages\interactions\models\internal\callback.py", line 43, in call_with_binding
    return await callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\coding_projects\Python_projects\eZwizard3-bot\main.py", line 831, in do_resign
    await _do_cheats(ctx,save_files,account_id,DUMMY_CHEAT_FUNC)
RuntimeError: coroutine ignored GeneratorExit

why?

lucid geodeBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

cold bear
#

What code do you have?

hardy coral
#

i have plenty of async code in there

#

and it does take a while sometimes slash commands

#

15 mins+

cold bear
#

What's the code of the command?

hardy coral
cold bear
#

What's the do_resign function?

hardy coral
# cold bear What's the `do_resign` function?
async def _(ftp: aioftp.Client, mount_dir: str, save_name: str): """Resigned Saves"""
DUMMY_CHEAT_FUNC = CheatFunc(_,{})
@interactions.slash_command(name="resign", description=f"Resign save files to an account id (max {MAX_RESIGNS_PER_ONCE} saves per command)")
@interactions.slash_option('save_files','The save files to resign too',interactions.OptionType.STRING,True)
@account_id_opt
async def do_resign(ctx: interactions.SlashContext,save_files: str,account_id: str):
    await base_do_cheats(ctx,save_files,account_id,DUMMY_CHEAT_FUNC)
hardy coral
#

@cold bear any idea? this is a very bad bug that if happens at wrong time can mess up my bot

#

it skips running any async with __aexit__

cold bear
#

What's account_id_opt?

hardy coral
# cold bear What's `account_id_opt`?
def account_id_opt(func):
    return interactions.slash_option(
    name="account_id",
    description="The account id to resign the saves to, put 0 for account id in database and 1 for no resign",
    required=True,
    max_length=16,
    min_length=1,
    opt_type=interactions.OptionType.STRING
    )(func)
cold bear
#

The exit of TemporaryDirectory?

hardy coral
# cold bear What does this mean?
async with mounted_saves_at_once:
    a: tuple[list[CheatFuncResult],PS4AccountID] = await apply_cheats_on_ps4(ctx,account_id,bin_file,white_file,enc_tp,my_cheats_chain,save_dir_ftp)

when that error happens this async generator's __aexit__ is never called, which i need it to do so

hardy coral
hardy coral
cold bear
#

My guess is that a coroutine is capturing GeneratorExit at some point (likely a try/finally), doesn't reraise it correctly, and that's why it crashes

#

I'm not sure why that's being thrown in the first place though

hardy coral
#

which confuses me

cold bear
#

@coarse yarrow Pulling you in, since I have no clue what the issue is

coarse yarrow
#

honestly with this less code i wouldnty be able to say anything

#

just on top of my head though

#

async with TemporaryDirectory() as tp: should be with TemporaryDirectory() as tp:, there's no way thats async

hardy coral
coarse yarrow
#

ah

#

then yeah, that parts fine

#

this makes me wonder about something else that im going to test in a second though

#

yeah nvm'

hardy coral