disnake icon indicating copy to clipboard operation
disnake copied to clipboard

Delayed command sync is not cancelled on termination

Open jgayfer opened this issue 3 years ago • 9 comments

Summary

Delayed command sync is not cancelled on termination

Reproduction Steps

When shutting down the bot, the delayed_command_sync task fails to be cancelled as it's in a pending state. Note that this occurs when no slash commands are registered.

ERROR:asyncio:Task was destroyed but it is pending!
task: <Task pending name='disnake: delayed_command_sync' coro=<InteractionBotBase._delayed_command_sync() done, defined at disnake/ext/commands/interaction_bot_base.py:795> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x10af24160>()]>>

Minimal Reproducible Code

No response

Expected Results

There should not be unhandled errors when shutting down.

Actual Results

There are internal errors on shutdown.

Intents

N/A

System Information

https://github.com/EQUENOS/disnake/commit/74403d440ee786bd9b5361e340a9c5439b932b53

Checklist

  • [X] I have searched the open issues for duplicates.
  • [X] I have shown the entire traceback, if possible.
  • [X] I have removed my token from display, if visible.

Additional Context

No response

jgayfer avatar Oct 24 '21 03:10 jgayfer

Thank you for reporting this, it's now fixed

EQUENOS avatar Oct 24 '21 10:10 EQUENOS

Thank you for reporting this, it's now fixed

You sure? Can continue to reproduce with this environment.

  • Python v3.8.11-final
  • disnake v2.2.1-beta
    • disnake pkg_resources: v2.2.1
  • aiohttp v3.7.4.post0

Installation was with pip install "disnake[discord]"

onerandomusername avatar Nov 10 '21 00:11 onerandomusername

I have also reproduced this issue on py 3.10

And with the current master branch (which installs as 2.2.0, even though 2.2.1 is what is on pypi)

And without the shims as well. I believe there is some problem with subclassing the bot and implementing custom methods, so I will removing and modifying those.

onerandomusername avatar Nov 10 '21 07:11 onerandomusername

I have also reproduced this issue on py 3.10

And with the current master branch (which installs as 2.2.0, even though 2.2.1 is what is on pypi)

And without the shims as well. I believe there is some problem with subclassing the bot and implementing custom methods, so I will removing and modifying those.

This issue should not happen unless you overwrite the close method. Could you share more details?

EQUENOS avatar Nov 12 '21 21:11 EQUENOS

I have also reproduced this issue on py 3.10

And with the current master branch (which installs as 2.2.0, even though 2.2.1 is what is on pypi)

And without the shims as well. I believe there is some problem with subclassing the bot and implementing custom methods, so I will removing and modifying those.

This issue should not happen unless you overwrite the close method. Could you share more details?

I have overwritten the close method, but is also calls the super's close method. I will experiment more with disnake tomorrow and update again.

onerandomusername avatar Nov 25 '21 22:11 onerandomusername

Turns out this happens unless I have around a two second wait after I await super().close()

And it somehow seems related to my own aiohttp session, very confused.

onerandomusername avatar Nov 27 '21 07:11 onerandomusername

I can no longer recreate this, so either its been fixed, or there's a lot of requirements.

onerandomusername avatar Jan 24 '22 18:01 onerandomusername

What a coincidence, I wanted to close this issue today!

EQUENOS avatar Jan 24 '22 18:01 EQUENOS

As evidenced by logs today, this is still occuring. TLDR we're using create_task when we should be saving the task and canceling it when closing the class object.

onerandomusername avatar Aug 01 '22 02:08 onerandomusername