-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Possibility of Event loop is closed
warning after Bot shutdown
#2997
Comments
Closing since this is fixed upstream: python/cpython#92841 (comment) |
@harshil21 But we support versions lower then 10, and they can see that error. I would either set the proper event loop or throw a warning if it isn't set on the non fixed versions |
@Poolitzer chances that someone bumps into this are rare, so far I've seen this happen due to another (unrelated) error happening. So I don't think we need to take any action just yet. |
@harshil21 I tend to agree with harshil here, though I think keeping the issue open doesn't hurt. Also gives users a chance to see that we're aware of it give input about this situation |
@Bibo-Joshi Is there a real problem here? Data loss? Or is it just an annoying log at shutdown time? If the latter and the problem is with python I think that closing as wontfix is appropriate. |
@tsnoam I'm not entirely sure tbh. would have to double check … |
I can't find any indication that the unexpected shutdown happens before any shutdown logic. In fact, while I can reproduce the issue with the example from above (where from telegram import Bot
import asyncio
async def bot_initialize():
async with Bot("TOKEN"):
pass
asyncio.run(bot_initialize()) where we properly shut down the bot, the error does not appear. Hence, it looks like the problem only happens if the user doesn't properly free resources in the first place. Hence, I'll close as wontfix. Still, if someone comes across the issue in a more sane setting, we should definitely reopen. |
While testing our code, we became aware that there could be a chance that we get an
Event loop is closed
error after shutting down the bot. This seems to only affect Windows and python versions 3.8+ and is related toProactorEventLoop
event loop policy on Windows.MRE:
The problem is most likely not with our library but with CPython itself, see python/cpython#83413 and encode/httpx#914.
A workaround would be to switch our default event loop policy to
WindowsSelectorEventLoopPolicy
, which is now what we do in tests. If multiple users are facing this problem frequently, we could consider switching.If anybody is willing to dig into this further and figure out when/how/why exactly this error occurs, that would be great.
Python versions affected:
3.8, 3.9
The text was updated successfully, but these errors were encountered: