Skip to content

Commit d6325b1

Browse files
committed
fix: guard eager task regression test by Python version
1 parent fd97336 commit d6325b1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

tests/test_rpc.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,12 +680,16 @@ async def test_spawn_agent_process_roundtrip(tmp_path):
680680

681681
@pytest.mark.asyncio
682682
async def test_connection_init_under_eager_task_factory(server):
683+
eager_task_factory = getattr(asyncio, "eager_task_factory", None)
684+
if eager_task_factory is None:
685+
pytest.skip("asyncio.eager_task_factory requires Python 3.12+")
686+
683687
# Regression: under asyncio.eager_task_factory the receive loop runs synchronously
684688
# up to its first await inside Connection.__init__, so every attribute it reads
685689
# (e.g. _receive_timeout) must be assigned before _tasks.create(_receive_loop()).
686690
loop = asyncio.get_running_loop()
687691
previous_factory = loop.get_task_factory()
688-
loop.set_task_factory(asyncio.eager_task_factory)
692+
loop.set_task_factory(eager_task_factory)
689693
try:
690694
conn = Connection(
691695
lambda method, params, is_notification: None,

0 commit comments

Comments
 (0)