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

"RuntimeError: Event loop is closed" on 3.8/win32 #9060

Closed
chlowell opened this issue Dec 9, 2019 · 1 comment
Closed

"RuntimeError: Event loop is closed" on 3.8/win32 #9060

chlowell opened this issue Dec 9, 2019 · 1 comment
Assignees
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library.
Milestone

Comments

@chlowell
Copy link
Contributor

chlowell commented Dec 9, 2019

Using aiohttp 3.6.2 and azure-core 1.1.1 with Python 3.8/win32, this program:

import asyncio
from azure.core.pipeline.transport import AioHttpTransport, HttpRequest

async def main():
    transport = AioHttpTransport()
    request = HttpRequest('GET', 'https://www.bing.com')
    await transport.send(request)

asyncio.run(main())

Logs this to stderr:

Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0348F3D0>
Traceback (most recent call last):
  File "C:\Python38-32\Lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Python38-32\Lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Python38-32\Lib\asyncio\base_events.py", line 711, in call_soon
    self._check_closed()
  File "C:\Python38-32\Lib\asyncio\base_events.py", line 504, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Note the exception is logged to stderr; it doesn't crash the program. This may be related to aio-libs/aiohttp#4324. I see the same behavior with aiohttp 4.0.0a1 (and an appropriately modified AioHttpTransport).

This may also be related to aiohttp's shutdown behavior (see aio-libs/aiohttp#1925). The exception isn't logged when asyncio.run above is replaced with with:

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
@chlowell chlowell added Client This issue points to a problem in the data-plane of the library. Azure.Core labels Dec 9, 2019
@lmazuel lmazuel added this to the Backlog milestone Apr 13, 2020
@chlowell
Copy link
Contributor Author

I'm closing this issue because the SDK can't prevent this error being raised. As described in the first aiohttp issue I linked above, the error is due to different behavior of ProactorEventLoop as compared to SelectorEventLoop, will not be raised in a future version of aiohttp, and can be prevented by application-level workarounds (though those may not be worth using because the error typically causes only a noisy shutdown).

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library.
Projects
None yet
Development

No branches or pull requests

2 participants