-
Notifications
You must be signed in to change notification settings - Fork 37
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
Asyncio streams are not being closed #133
Comments
@thesadru Would you mind verifying this is fixed with v6.1.0? |
The error persists, there's still no |
Actually, to add to this I think it'd be a good idea to just put the |
If you have a script that produces the error at least semi-reliably, I would convert that into a unit test to fix this. Please share 😄 |
I'm super sorry. It seems I caused the bug myself by messing with the library's source code. I didn't find out because the library was technically up to date. I reinstalled it and it works fine now. I apologize for the inconvenience. |
Oops, guess I was too hasty writing this off as just me messing with the source code. I'm getting the error again but only when I'm using import mcstatus
import asyncio
import discord
loop = asyncio.get_event_loop()
server = mcstatus.MinecraftServer.lookup('m.bylex.cz')
loop.create_task(server.async_status())
bot = discord.Client()
bot.run(TOKEN)
|
It is not yet clear to me which library would cause that asyncio stacktrace. I also could not reproduce the issue when I tried earlier. Would you mind making a small reproduce repo (or gist) that has dependencies locked to the same versions that are giving you the error? I'm picturing:
Of course, feel free to deviate from these instructions so long as it is easy to reproduce the error. It's hard for me to fix if I can't make it happen and debug it. |
https://gist.github.com/thesadru/131af37792b300c002d09de4ec3b0a44 |
This does seem to be a windows specific bug related to asyncio sockets using Protractor. I found a lot of good information in this issue and a fix encode/httpx#914 (comment) This seems to make the issue disappear: import asyncio
import os
import sys
import discord
import mcstatus
if sys.version_info[0] == 3 and sys.version_info[1] >= 8 and sys.platform.startswith('win'):
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
server = mcstatus.MinecraftServer.lookup('m.bylex.cz')
async def server_status():
status = await server.async_status()
print(status.raw)
loop = asyncio.get_event_loop()
task = loop.create_task(server_status())
bot = discord.Client()
bot.run(os.environ['TOKEN']) I'm going to close the issue and mark it as invalid since it is not a bug within mcstatus as far as I can tell. I'll add this to my ongoing list of things to include in #136 |
Whenever an async function is called a connection gets opened, but this connection never gets closed. This causes exceptions to be raised
This can be fixed by simply calling
connection.writer.close()
right before the return.The text was updated successfully, but these errors were encountered: