Search code examples
python-3.xkubernetesfastapiuvicorn

During uvicorn startup child process dies in Kubernetes cluster


We are using FastAPI version 0.111.0 for our application. Starting uvicron server like below, this works on windows machine during our development/test environment. When we deploy this code in Azure Kubernets cluster, during startup child process dies

  uvicorn.run(
                "main:app",
                host='0.0.0.0',
                port=8080,
                log_level="DEBUG",
                workers=3
            )

Error message:

INFO:     Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
INFO:     Started parent process [1]
INFO:     Waiting for child process [12]
INFO:     Child process [12] died
INFO:     Waiting for child process [13]
INFO:     Child process [13] died
INFO:     Waiting for child process [14]
INFO:     Child process [14] died
INFO:     Waiting for child process [13]
INFO:     Child process [13] died
INFO:     Waiting for child process [15]

If we remove the workers argument for the uvicron.run call, the application starts in AKS. I would like to understand, why child process dies with workers argument.

Thanks


Solution

  • It seems, this is a bug: https://github.com/encode/uvicorn/discussions/2372

    It will be fixed at v0.30.2: https://github.com/encode/uvicorn/pull/2380