fix(workspace): replace asyncio.get_event_loop().run_until_complete with asyncio.run() (#307)
test_a2a_tools_inbox_wrappers.py's _run() helper used asyncio.get_event_loop().run_until_complete() to run coroutines from sync test methods. When pytest-asyncio is active in OTHER test files in the same suite, get_event_loop() can return the shared pytest-asyncio loop, and run_until_complete() raises "loop already running" errors. Fix: replace with asyncio.run(), which creates a fresh loop each call. Result (full suite, 14→0 for inbox wrappers): Without fix: 10 failures (6 TestToolWaitForMessage + 4 delegation) With fix: 4 failures (all pre-existing delegation polling) Closes #307.
This commit is contained in:
parent
912fba4a79
commit
4441f0c237
@ -30,7 +30,15 @@ def _require_workspace_id(monkeypatch):
|
||||
|
||||
|
||||
def _run(coro):
|
||||
return asyncio.get_event_loop().run_until_complete(coro)
|
||||
# Use asyncio.run() to create a fresh event loop each call.
|
||||
# Previously used asyncio.get_event_loop().run_until_complete(), which
|
||||
# pollutes the shared loop when pytest-asyncio is active in other
|
||||
# test files in the same suite — pytest-asyncio manages its own loop
|
||||
# per async test, and get_event_loop() in a sync context can return
|
||||
# that shared loop, causing "loop already running" errors in the
|
||||
# full suite (14 tests pass in isolation, fail in full suite).
|
||||
# asyncio.run() creates a new loop, avoiding the conflict.
|
||||
return asyncio.run(coro)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user