`serve()` fails on Python 3.14: `asyncio.get_event_loop()` raises instead of creating a loop
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 58/100
Direção de pesquisa
Comece em crossplane/function/runtime.py por volta da linha 98 e siga serve() passando pela configuração do manipulador de sinais e pela chamada a run_until_complete. Compare o intervalo de Python declarado em pyproject.toml com a cobertura de uma única versão em .github/workflows/ci.yml e, em seguida, reproduza a falha usando function-template-python com python:3.14-slim. Considera-se concluído quando o entrypoint inicia e atende a requisições no Python 3.14 sem quebrar a suíte existente.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Python
- Estrelas
- 12
- Forks
- 15
- Merge médio
- 1d 12h
- PRs com merge (30d)
- 7
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de crossplane/function-sdk-python
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
-
enhancement
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 42/100
-
enhancement
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
crossplane/function-sdk-python#199 · 4 comentários · 3 reações ·
-
bug
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
crossplane/function-sdk-python#129 · 1 comentário ·
-
Dependency Dashboard Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 10/100
Todas as issues de crossplane/function-sdk-python
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
anthropics/skills#1811 · 1 comentário ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
speaches-ai/speaches#678 ·
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
datalayer/mcp-compose#42 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
conda-forge/spacy-feedstock#177 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
UKGovernmentBEIS/inspect_evals#2523 ·