Skip to content
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

window10 ProactorEventLoop does't not exit normally when task has finished #3359

Closed
woshimanong1990 opened this issue Oct 22, 2018 · 6 comments

Comments

@woshimanong1990
Copy link

Long story short

Expected behaviour

`# coding:utf-8

import aiohttp
import asyncio

async def fetch(session, url):
async with session.get(url) as response:
return await response.text()

async def main():
async with aiohttp.ClientSession() as session:
html = await fetch(session, 'http://python.org')
print(html)

loop = asyncio.ProactorEventLoop()
asyncio.set_event_loop(loop)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())`

It exits normalley; However, when I use SelectorEventLoop, it works!

Actual behaviour

In face ,the program does't not exit; When I write result to a file, the content is not written to file;

It does't exit; when I attempt to close the loop, Error happen;
Exception ignored in: <bound method _ProactorBasePipeTransport.__del__ of <_ProactorSocketTransport closing fd=836 read=<_OverlappedFuture cancelled>>> Traceback (most recent call last): File "d:\software\programe\python35\Lib\asyncio\proactor_events.py", line 96, in __del__ self.close() File "d:\software\programe\python35\Lib\asyncio\proactor_events.py", line 84, in close self._loop.call_soon(self._call_connection_lost, None) File "d:\software\programe\python35\Lib\asyncio\base_events.py", line 572, in call_soon self._check_closed() File "d:\software\programe\python35\Lib\asyncio\base_events.py", line 357, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed Exception ignored in: <bound method _ProactorBasePipeTransport.__del__ of <_ProactorSocketTransport closing fd=876 read=<_OverlappedFuture cancelled>>> Traceback (most recent call last): File "d:\software\programe\python35\Lib\asyncio\proactor_events.py", line 96, in __del__ self.close() File "d:\software\programe\python35\Lib\asyncio\proactor_events.py", line 84, in close self._loop.call_soon(self._call_connection_lost, None) File "d:\software\programe\python35\Lib\asyncio\base_events.py", line 572, in call_soon self._check_closed() File "d:\software\programe\python35\Lib\asyncio\base_events.py", line 357, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed

Steps to reproduce

run the code
`# coding:utf-8

import aiohttp
import asyncio

async def fetch(session, url):
async with session.get(url) as response:
return await response.text()

async def main():
async with aiohttp.ClientSession() as session:
html = await fetch(session, 'http://python.org')
print(html)

loop = asyncio.ProactorEventLoop()
asyncio.set_event_loop(loop)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()`

Your environment

window10 + python 3.5.3

@aio-libs-bot
Copy link

GitMate.io thinks the contributor most likely able to help you is @asvetlov.

Possibly related issues are #376 (ProactorEventLoop hangs ), #1559 (Lingering close doesn't terminate before timeout), #2038 (add_route does not allow **kwargs), #3075 (trust_env doesn't works), and #2309 (WebSocketResponse does not throw/close when connection is abruptly cut).

@woshimanong1990
Copy link
Author

Now try to run the same code on python 3.7.1. Unbelievably, it seem to run normally. Maybe it's a python bug!

@woshimanong1990
Copy link
Author

python 3.6.5 also works!

@woshimanong1990
Copy link
Author

I think it's a bug!

@asvetlov
Copy link
Member

Several proactor problems were fixed in 3.6
You report definitely is not related to aiohttp itself, closing it.

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants