Skip to content

Commit abc481a

Browse files
Fix tests for Python3.14
asyncio.get_event_loop() started raising a RuntimeError if there was no loop running.
1 parent e319f73 commit abc481a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

tests/sim_asyncio_ioc_override.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@
3737

3838
# Run the IOC
3939
builder.LoadDatabase()
40-
event_loop = asyncio.get_event_loop()
40+
try:
41+
event_loop = asyncio.get_event_loop()
42+
except RuntimeError:
43+
event_loop = asyncio.new_event_loop()
4144
worker = threading.Thread(target=event_loop.run_forever)
4245
worker.daemon = True
4346
worker.start()
@@ -49,6 +52,7 @@
4952
try:
5053
from pytest_cov.embed import cleanup
5154
sys._run_exitfuncs = cleanup
55+
5256
except ImportError:
5357
# Note that pytest_cov.embed no longer exists in pytest_cov>=7.0.0
5458
pass

tests/test_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ async def test_asyncio_ioc_override(asyncio_ioc_override):
133133
def test_asyncio_dispatcher_event_loop():
134134
"""Test that passing a non-running event loop to the AsyncioDispatcher
135135
raises an exception"""
136-
event_loop = asyncio.get_event_loop()
136+
try:
137+
event_loop = asyncio.get_event_loop()
138+
except RuntimeError:
139+
event_loop = asyncio.new_event_loop()
137140
with pytest.raises(ValueError):
138141
AsyncioDispatcher(loop=event_loop)
139142

0 commit comments

Comments
 (0)