While I was reporting another bug, I saw that 1.4 was released, thanks for that.
I simply trying to shut down the bot via command after updating form 1.3.4 to 1.4.1 but an error occurs.
Note: However, it is not clear to me why I cannot find the exact position while debugging and the programm is terminating unfinished.
import logging
from discord.ext.commands import Bot
from discord.ext.commands import Context
logging.basicConfig(level=logging.INFO)
if __name__ == '__main__':
b = Bot('!')
@b.command()
async def quit(ctx: Context):
await ctx.send('Bye.')
await ctx.bot.logout()
return
b.run(<Token>)
A normal shutdown of the bot and that it is immediately offline in discord.
INFO:discord.gateway:Websocket closed with 1000, cannot reconnect.
INFO:discord.client:Cleaning up tasks.
INFO:discord.client:Closing the event loop.
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000019AB4C88310>
Traceback (most recent call last):
File "<Path>\Anaconda3\envs\env\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "<Path>\Anaconda3\envs\env\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "<Path>\Anaconda3\envs\env\lib\asyncio\base_events.py", line 719, in call_soon
self._check_closed()
File "<Path>\Anaconda3\envs\env\lib\asyncio\base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
discord.py-1.4.1
python-3.8.3
aiohttp-3.6.2
Windows10
Duplicate of #5209.
/ See https://github.com/Rapptz/discord.py/issues/5209#issuecomment-670161023
Thx, I missed it, since it is closed
Sorry that issue is not relevant is this case, this is actually an Anaconda bug where anaconda wants the main thread and can't have it and so the event loop breaks.
This has been an issue for quite some time, though I can only however find stackoverflow posts relating to Jupyter Notebooks with this issue.
No Problem. Should this issue be closed?
Anaconda and Jupyter both use the ipython kernel, which as of version 7 has its own intrinsic asyncio event loop support. The problem is that the run() method in discord.py handles the creation and teardown of the event loop for you, assuming you are using the standard python interpreter. There ARE ways to configure ipython to work around this, as well as not using bot.run() in discord.py, but the easiest one is to just run your bot with said standard python interpreter.
I would say, yeah, this should probably be closed as on the discord.py side, it's intended behavior.
Most helpful comment
Sorry that issue is not relevant is this case, this is actually an Anaconda bug where anaconda wants the main thread and can't have it and so the event loop breaks.
This has been an issue for quite some time, though I can only however find stackoverflow posts relating to Jupyter Notebooks with this issue.