Skip to content

[Bug]: FastAPI server shutdown raises AttributeError: 'FastAPI' object has no attribute 'state' #2580

@pjh4993

Description

@pjh4993

Your current environment

The output of python collect_env.py
OS                           : Ubuntu 24.04.1 LTS (x86_64)
PyTorch version              : 2.10.0+cu128
Python version               : 3.12.11
CUDA runtime version         : Could not collect
GPU 0-3: NVIDIA B200
Nvidia driver version        : 580.126.09
vLLM Version                 : 0.19.0
vLLM-Omni Version            : 0.19.0rc2.dev32+g408365fa0 (git sha: 408365fa0)

Your code version

The commit id or version of vllm
vllm==0.19.0
The commit id or version of vllm-omni
408365fa (main branch, 2026-04-08)

🐛 Describe the bug

During pytest execution with pytest -v -s -m "core_model and cpu", every comfyui integration test logs the following AttributeError from the APIServer subprocess on shutdown:

(APIServer pid=XXXXX) Traceback (most recent call last):
  File ".../tests/comfyui/test_comfyui_integration.py", line 452, in run_server
    cmd.cmd(args)
  File ".../vllm_omni/entrypoints/cli/serve.py", line 94, in cmd
    uvloop.run(omni_run_server(args))
  ...
  File ".../vllm_omni/entrypoints/openai/api_server.py", line 356, in omni_run_server_worker
    app.state.openai_serving_speech.shutdown()
    ^^^^^^^^^
AttributeError: 'FastAPI' object has no attribute 'state'

Observed behavior:

  • The error appears on every comfyui test (18/18 tests) consistently
  • Tests themselves still PASS — the error occurs in the APIServer child process during shutdown, after the test assertions have completed
  • Reproduced on both main branch (408365f) and a feature branch based on it

How to reproduce:

pytest -v -s -m "core_model and cpu" -k "comfyui" 2>&1 | grep "AttributeError"

Output:

(APIServer pid=562371) AttributeError: 'FastAPI' object has no attribute 'state'
(APIServer pid=562377) AttributeError: 'FastAPI' object has no attribute 'state'
... (repeated for all 18 comfyui tests)

Root cause:
In vllm_omni/entrypoints/openai/api_server.py:356, the finally block in omni_run_server_worker calls app.state.openai_serving_speech.shutdown(), but by that point uvicorn has already torn down the FastAPI app and app.state is no longer accessible.

Verified that adding a getattr guard eliminates the error while all 18 tests continue to pass.

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions