Skip to content

[ci-scan] Fix crossgen2_comparison.py Python 3.14 asyncio compatibility#129029

Merged
jkotas merged 4 commits into
mainfrom
ci-scan/fix-crossgen2-comparison-py314-c0554dc511ac8fab
Jun 12, 2026
Merged

[ci-scan] Fix crossgen2_comparison.py Python 3.14 asyncio compatibility#129029
jkotas merged 4 commits into
mainfrom
ci-scan/fix-crossgen2-comparison-py314-c0554dc511ac8fab

Conversation

@github-actions

@github-actions github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the RuntimeError: There is no current event loop in thread 'MainThread' crash in crossgen2_comparison.py on macOS Helix machines that have upgraded to Python 3.14.

Changes

Replaced the deprecated pattern:

loop = asyncio.get_event_loop()
loop.run_until_complete(coro)
loop.close()

with the modern equivalent:

asyncio.run(coro)

asyncio.run() was introduced in Python 3.7, respects the event loop policy (including the WindowsProactorEventLoopPolicy set in __init__), and is the recommended replacement for the removed implicit event loop behavior.

Motivation

Python 3.14 removed the deprecated implicit event loop creation in asyncio.get_event_loop() when called from the main thread with no running loop. This broke the crossgen2_comparison.py script on macOS arm64 Helix agents where Homebrew installed Python 3.14.

Affected pipeline: runtime-coreclr crossgen2 outerloop (def 134) — osx-arm64 leg

Fixes #129211

Testing

The fix is a straightforward API migration with identical semantics. The script's existing test coverage (crossgen2 comparison runs) validates correctness.

Note

🔒 Integrity filter blocked 5 items

The following items were blocked because they don't meet the GitHub integrity level.

  • #83226 search_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #110472 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #100356 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #104275 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #77540 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

Generated by CI Outer-Loop Failure Scanner · ● 100.8M ·

Replace deprecated asyncio.get_event_loop()/run_until_complete()/close()
pattern with asyncio.run(), which is compatible with Python 3.7+ and fixes
the RuntimeError on Python 3.14 where get_event_loop() raises when no
current event loop exists.

Fixes #128992

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jkotas

jkotas commented Jun 10, 2026

Copy link
Copy Markdown
Member

/azp run runtime-coreclr crossgen2 outerloop

@jkotas jkotas added area-ReadyToRun and removed area-crossgen2-coreclr only use for closed issues labels Jun 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the crossgen2 comparison test script to use asyncio.run(...) instead of manually creating/closing an event loop, improving compatibility with newer Python asyncio behavior.

Changes:

  • Replace asyncio.get_event_loop() + run_until_complete() + close() with asyncio.run(...) in AsyncSubprocessHelper.run_to_completion.
  • Keep the script’s async orchestration model intact (still uses asyncio.gather over scheduled tasks).

Comment thread src/tests/Common/scripts/crossgen2_comparison.py
@jkotas

jkotas commented Jun 10, 2026

Copy link
Copy Markdown
Member

/azp run runtime-coreclr crossgen2 outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jkotas

jkotas commented Jun 12, 2026

Copy link
Copy Markdown
Member

/ba-g known infra timeouts. Change affects crossgen outerloop only that's not covered by build analysis.

@jkotas jkotas merged commit 9db0b29 into main Jun 12, 2026
108 of 131 checks passed
@jkotas jkotas deleted the ci-scan/fix-crossgen2-comparison-py314-c0554dc511ac8fab branch June 12, 2026 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ci-scan] Build break: crossgen2_comparison.py fails with Python 3.14 asyncio

2 participants