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

asyncio internals throw RuntimeError: Event loop is closed on script exit #92841

Closed
arhadthedev opened this issue May 16, 2022 · 3 comments
Closed
Labels
expert-asyncio type-bug An unexpected behavior, bug, or error

Comments

@arhadthedev
Copy link
Contributor

arhadthedev commented May 16, 2022

Actual behavior

>>> import asyncio
>>> import aiohttp
>>>
>>> async def main():
...     async with aiohttp.ClientSession() as session:
...         async with session.get('https://example.com/'):
...             pass
...
>>> asyncio.run(main())
>>> exit()
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000017BF133F760>
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Program Files\Python310\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Program Files\Python310\lib\asyncio\base_events.py", line 750, in call_soon
    self._check_closed()
  File "C:\Program Files\Python310\lib\asyncio\base_events.py", line 515, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

This issue was reported in aio-libs/aiohttp#4324 so the reproducer is copied from there.

Expected behavior

Normal exit without termination. There is no user-created loop to be closed manually.

Your environment

  • CPython versions tested on: 3.10.4
  • Operating system and architecture: Windows 10
@arhadthedev arhadthedev added the type-bug An unexpected behavior, bug, or error label May 16, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 17, 2022
…honGH-92842)

(cherry picked from commit 33880b4)

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 17, 2022
…honGH-92842)

(cherry picked from commit 33880b4)

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
miss-islington added a commit that referenced this issue May 17, 2022
(cherry picked from commit 33880b4)

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
@hauntsaninja
Copy link
Contributor

hauntsaninja commented May 22, 2022

Thanks, seems like we can close this one out

@hauntsaninja
Copy link
Contributor

hauntsaninja commented May 22, 2022

Oh never mind, the 3.10 backport hasn't been merged

@hauntsaninja hauntsaninja reopened this May 22, 2022
ambv pushed a commit that referenced this issue Jun 28, 2022
…GH-92904)

(cherry picked from commit 33880b4)

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expert-asyncio type-bug An unexpected behavior, bug, or error
Projects
Status: Done
Development

No branches or pull requests

3 participants