[Python 3.14 proxy worker] Missing sys.modules["__main__"] breaks multiprocessing spawn
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Inizia individuando il percorso di pulizia delle dipendenze di proxy_worker per Python 3.14 descritto nell'indagine e riproduci il fallimento con l'esempio minimo di multiprocessing spawn. Traccia il motivo per cui main viene rimosso, quindi verifica che la riproduzione possa avviare ed eseguire correttamente il join del processo figlio senza compromettere il comportamento di pulizia del worker.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
The Azure Functions Python 3.14 proxy worker removes __main__ from
sys.modules before invoking application code.
As a result, Python's standard multiprocessing spawn context fails during
Process.start(), before the child process or its target function begins
executing.
This is not specific to any third-party package. The minimal reproduction uses
only azure-functions and the Python standard library.
Environment
- Azure Functions Python runtime: 3.14
- Python: 3.14.6
- Azure Functions Core Tools: 4.12.0
- Functions runtime: 4.1048.200.26180
- Programming model: Python v2
azure-functionsapplication package: 2.2.0- Reproduced locally inside the Functions worker
- The same failure was observed after deploying the application to Azure Functions on Python 3.14
The same application code worked on the Python 3.12 Functions runtime.
Minimal reproduction
import multiprocessing
import sys
import azure.functions as func
app = func.FunctionApp()
def child_process() -> None:
return None
@app.route(route="multiprocessing-repro")
def multiprocessing_repro(req: func.HttpRequest) -> func.HttpResponse:
main_present = "__main__" in sys.modules
context = multiprocessing.get_context("spawn")
process = context.Process(target=child_process)
process.start()
process.join()
return func.HttpResponse(
f"__main__ present: {main_present}; exit code: {process.exitcode}"
)
Start the application using Core Tools with Python 3.14 and invoke
/api/multiprocessing-repro.
Actual behavior
"__main__" in sys.modules is false during the function invocation, and
Process.start() raises:
Traceback (most recent call last):
File ".../multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File ".../multiprocessing/context.py", line 289, in _Popen
return Popen(process_obj)
File ".../multiprocessing/popen_spawn_posix.py", line 32, in __init__
super().__init__(process_obj)
File ".../multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File ".../multiprocessing/popen_spawn_posix.py", line 42, in _launch
prep_data = spawn.get_preparation_data(process_obj._name)
File ".../multiprocessing/spawn.py", line 164, in get_preparation_data
main_module = sys.modules["__main__"]
KeyError: "__main__"
The failure occurs before the child process starts.
Expected behavior
The Functions worker should retain a valid __main__ module, or otherwise
initialize the application environment so that standard-library
multiprocessing spawn works inside a function invocation.
Investigation
The Python 3.14 worker uses proxy_worker. Its dependency cleanup appears to
remove modules from sys.modules based on their file location. It excludes
modules whose names begin with proxy_worker, but does not appear to exclude
__main__.
That appears to leave the invocation environment without the module required
by multiprocessing.spawn.get_preparation_data().
Launching an explicit Python subprocess with an importable module works in the
same Functions-host process, confirming that the failure is specifically in
the multiprocessing spawn preparation path.
Impact
Any application or dependency that uses the standard-library spawn context can
fail under the Python 3.14 Functions worker. In our application this prevented
all isolated document conversions from starting, regardless of document type.
Related issue
Related historical issue: #1094 reported the same missing-__main__ worker
condition on Python 3.9 through a different caller.
This report concerns the Python 3.14 proxy worker and reproduces through:
multiprocessing.get_context("spawn").Process(...).start()
It is therefore related behavior, but not the same caller or worker
implementation.
- Lingua principale
- Python
- Stelle
- 357
- Fork
- 117
- Merge medio
- 13g 12h
- PR unite (30g)
- 2
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Azure/azure-functions-python-worker
-
[Bug] ASGI cookie conversion serializes an absent Domain attribute and breaks __Host- cookiesForse già presa @tharun06 l’ha presa 22 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
Azure/azure-functions-python-worker#1908 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
Azure/azure-functions-python-worker#1906 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
-
bug python
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
Azure/azure-functions-python-worker#1887 · 1 reazione ·
Tutte le issue di Azure/azure-functions-python-worker
Issue simili
-
[Bug]: LangGraph Store sync put bypasses namespace validationForse già presa @ktz03 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
volcengine/OpenViking#6050 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Streamed /v1/chat/completions sends unredacted agent error text (keys) in the final chunkForse già presa @rodricksz4h5 l’ha presa oggi. Apertaarea/streaming comp/gateway P2 type/security
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NousResearch/hermes-agent#138245 ·
I maintainer di solito rispondono entro 1 giorno
-
[oblt-aw][autodoc] Update user onboarding guide for mandatory trigger CODEOWNERS stepForse già presa @github-actions l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
correction metadata
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 68/100
acl-org/acl-anthology#10378 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
cloudtrail_multi_region_enabled_logging_management_events fails when the advanced event selector has a custom nameForse già presa @12YYCCYY16 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
prowler-cloud/prowler#13033 ·
I maintainer di solito rispondono entro 1 giorno