Skip to content

asyncio.get_event_loop() used inside async code will warn on 3.12 and raise on 3.14 #50

@nficano

Description

@nficano

Three call sites construct asyncio.Future objects via asyncio.get_event_loop().create_future() from inside coroutines: src/arcp/_client/handles.py:28 builds the terminal future for every JobHandle, src/arcp/_client/ops.py:72 builds the accept future for every submit_job, and src/arcp/_runtime/_accept.py:60 builds the heartbeat-outcome future at session start. asyncio.get_event_loop() is deprecated when called without a running loop since Python 3.10, emits a DeprecationWarning on 3.12 in some scenarios, and is scheduled to raise inside coroutines on 3.14 per CPython issue gh-100160. The project's pytest config sets filterwarnings = ["error", "ignore::DeprecationWarning"] at pyproject.toml:117, so this warning is suppressed in CI and will surface only when downstream consumers turn warnings into errors or upgrade to 3.14. Every one of these call sites is reached from inside async def, so the correct API is asyncio.get_running_loop().create_future(), which fails fast instead of falling back to thread-local loop policies.

Fix prompt: Replace asyncio.get_event_loop() with asyncio.get_running_loop() at src/arcp/_client/handles.py:28, src/arcp/_client/ops.py:72, and src/arcp/_runtime/_accept.py:60. Verify there are no other call sites with grep -rn "get_event_loop" src tests examples. Construct JobHandle._terminal lazily on first access if the handle must remain constructible outside an async context for tests; otherwise document that JobHandle.__init__ must be called from within a running loop. Add a unit test that constructs ARCPClient, submits via the in-memory transport, and asserts no DeprecationWarning is emitted when run with -W error::DeprecationWarning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingseverity:mediumMedium severity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions