Repository navigation
IsolatedAsyncioTestCase freezes when exception is raised #83282
Copy link
Copy link
Closed
Labels
3.8 (EOL)end of lifeend of lifetopic-asynciotype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
Activity
IsolatedAsyncioTestCase freezes whenever an exception that inherits from BaseException is raised:
import unittest class TestHangsForever(unittest.IsolatedAsyncioTestCase): async def test_hangs_forever(self): raise BaseException("Hangs forever") if __name__ == "__main__": import unittest unittest.main()
A kind of similar issue present on 3.7 was fixed on 3.8 here https://github.com/python/cpython/blob/3.8/Lib/asyncio/events.py#L84, where BaseExceptions would not be correctly handled by the event loop, this seems somewhat related.
I had a look at IsolatedAsyncioTestCase implementation, did not spot any obvious broken thing there, I could use some light here. Thanks.
- added3.8 (EOL)end of lifeend of lifetype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
on Dec 19, 2019 Here is a variant that also hangs, I suspect for the same reason. The task raises asyncio.CancelledError which inherits from BaseException and my guess is it somehow kills the event loop.
import asyncio import unittest class DemonstrateHang(unittest.IsolatedAsyncioTestCase): async def test_hang(self): task = asyncio.create_task(asyncio.sleep(2)) await asyncio.sleep(0.1) task.cancel() await task # this also hangs: await asyncio.wait_for(task, 5)
Metadata
Metadata
Assignees
Labels
3.8 (EOL)end of lifeend of lifetopic-asynciotype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: