Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`serve()` fails on Python 3.14: `asyncio.get_event_loop()` raises instead of creating a loop

クローズ
#224 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python
領域
backend

調査の方向性

crossplane/function/runtime.py の 98 行目付近から始め、シグナルハンドラーのセットアップと run_until_complete の呼び出しを通じて serve() を追跡します。pyproject.toml で宣言されている Python の範囲と、.github/workflows/ci.yml における単一バージョンのカバレッジを比較し、その後 function-template-python で python:3.14-slim を使用して失敗を再現します。完了の条件は、既存のスイートを壊さずに 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時間
マージ済み PR(30日)
7

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

crossplane/function-sdk-python のほかの issue

crossplane/function-sdk-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。