Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
Closed
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixestopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
demo reproducer:
importunittestimportasyncioclassDemoTestCase1(unittest.IsolatedAsyncioTestCase): defsetUp(self): self.loop=asyncio.get_event_loop_policy().get_event_loop() asyncdeftest_demo(self): print("hello!") classDemoTestCase2(unittest.IsolatedAsyncioTestCase): defsetUp(self): self.loop=asyncio.get_event_loop_policy().get_event_loop() asyncdeftest_demo(self): print("hello!") if__name__=="__main__": unittest.main()see also #93896
graingert@conscientious testing310 ~/projects python3.10 foo.py hello! .hello! . ---------------------------------------------------------------------- Ran 2 tests in 0.002s OK graingert@conscientious testing310 ~/projects python3.11 foo.py hello! .E ====================================================================== ERROR: test_demo (__main__.DemoTestCase2.test_demo) ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/python3.11/unittest/async_case.py", line 82, in _callSetUp self._asyncioTestContext.run(self.setUp) File "/home/graingert/projects/foo.py", line 14, in setUp self.loop = asyncio.get_event_loop_policy().get_event_loop() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/events.py", line 677, in get_event_loop raise RuntimeError('There is no current event loop in thread %r.' RuntimeError: There is no current event loop in thread 'MainThread'. ---------------------------------------------------------------------- Ran 2 tests in 0.002s FAILED (errors=1) it looks like this is because asyncio.Runner calls asyncio.set_event_loop( in Runner.run
Metadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixestopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
Todo