`serve()` fails on Python 3.14: `asyncio.get_event_loop()` raises instead of creating a loop
還沒有人認領這個 Issue。
評估
研究方向
從 crossplane/function/runtime.py 第 98 行附近開始,追蹤 serve(),檢查其訊號處理器設定以及對 run_until_complete 的呼叫。將 pyproject.toml 中宣告的 Python 範圍與 .github/workflows/ci.yml 中單一版本的涵蓋情況進行比較,然後使用 function-template-python 和 python:3.14-slim 重現該故障。完成的標準是 entrypoint 能在 Python 3.14 上啟動並處理請求,同時不破壞現有測試套件。
由索引模型根據 Issue 內容生成。
描述
What happened?
crossplane.function.runtime.serve() calls asyncio.get_event_loop() from a
synchronous context:
https://github.com/crossplane/function-sdk-python/blob/main/crossplane/function/runtime.py#L98
On Python 3.14 that raises instead of creating a loop, so any function built on
the SDK dies at startup:
Traceback (most recent call last):
File "/app/.venv/bin/my-function", line 10, in <module>
sys.exit(main())
File "/app/function/main.py", line 42, in main
runtime.serve(
...
File "/app/.venv/lib/python3.14/site-packages/crossplane/function/runtime.py", line 98, in serve
loop = asyncio.get_event_loop()
File "/usr/local/lib/python3.14/asyncio/events.py", line 718, in get_event_loop
raise RuntimeError('There is no current event loop in thread %r.'
% threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'MainThread'.
get_event_loop() creating a loop when none is running was deprecated in 3.12
and removed in 3.14; the call now only succeeds from inside a running loop.
How can we reproduce it?
Scaffold from function-template-python, set the base image to
python:3.14-slim, build, and run the entrypoint — the process exits
immediately with the traceback above. Nothing else is needed; it fails before
any request is served.
What is the SDK version?
crossplane-function-sdk-python 0.14.0 (current release), and main at the
time of writing still has the same call.
Why this may have gone unnoticed
pyproject.toml declares requires-python = ">=3.11", but CI pins a single
version — PYTHON_VERSION: '3.11' in .github/workflows/ci.yml — so nothing
exercises the upper end of that range. 3.13 still accepts the call (deprecated
only), which is why this surfaces first on 3.14.
Additional context
Found while testing a Python 3.12 → 3.14 bump on a function of ours. Worth
flagging how quiet the failure is: on 3.14 the image builds, every dependency
imports, and the full unit suite passes. Only starting the entrypoint fails, so
the bump looks green everywhere except in a cluster, where it crash-loops.
Happy to test a patch against a real function if that helps — not opening a PR
myself, since serve() also installs signal handlers and calls
run_until_complete on that loop, and how you want it restructured (own loop
via new_event_loop, or moving to asyncio.run) is a design call for you.
- 主要語言
- Python
- 星號
- 12
- 分支
- 15
- 平均合併
- 1 天 12 小時
- 30 天內合併 PR
- 7
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
crossplane/function-sdk-python 的其他 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 68/100
-
enhancement
難度 5/5 一週以上 新手友好度 42/100
-
enhancement
難度 5/5 一週以上 新手友好度 35/100
crossplane/function-sdk-python#199 · 4 則留言 · 3 個 reaction ·
-
bug
難度 4/5 3-5 天 新手友好度 35/100
crossplane/function-sdk-python#129 · 1 則留言 ·
-
難度 1/5 1 小時以內 新手友好度 10/100
查看 crossplane/function-sdk-python 的全部 Issue
相似的 Issue
-
essnmx good first issue
難度 1/5 1 小時以內 新手友好度 95/100
-
難度 2/5 1-3 小時 新手友好度 65/100
syfoud/Simulated_Scepter#174 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
Giskard-AI/giskard-oss#2840 · 1 則留言 ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success 未關閉area: repo bug perceived difficulty: 2
難度 2/5 1-3 小時 新手友好度 70/100
-
難度 2/5 1-3 小時 新手友好度 75/100
yeti-platform/yeti#1380 ·