Skip to content

fix(runtime): use running loop for futures - #8202

Open
Rolly Calma (Ghraven) wants to merge 1 commit into
microsoft:mainfrom
Ghraven:raven-runtime-futures-running-loop
Open

fix(runtime): use running loop for futures#8202
Rolly Calma (Ghraven) wants to merge 1 commit into
microsoft:mainfrom
Ghraven:raven-runtime-futures-running-loop

Conversation

@Ghraven

Copy link
Copy Markdown

Problem

Several runtime send_message paths create futures from inside async methods with asyncio.get_event_loop().create_future().

Since these methods are already executing in a running event loop, asyncio.get_running_loop() is the more direct API and avoids relying on event-loop policy fallback behavior.

Before / after

Before, the single-threaded runtime and gRPC runtime paths asked the event-loop policy for a loop before creating response futures.

After, they create those futures from the currently running loop. The surrounding request tracking, cancellation linking, and background task behavior are unchanged.

Verification

  • python -m py_compile python/packages/autogen-core/src/autogen_core/_single_threaded_agent_runtime.py python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime_host_servicer.py python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime.py
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant