Skip to content

feat(k8s)#188

Draft
marcelklehr wants to merge 1 commit intomainfrom
feat/k8s
Draft

feat(k8s)#188
marcelklehr wants to merge 1 commit intomainfrom
feat/k8s

Conversation

@marcelklehr
Copy link
Member

SIGTERM is used by k8s to signal impending deletion of pods

@marcelklehr marcelklehr changed the title feat(sigterm): Listen for SIGTERM to stop listening for tasks feat(k8s) Feb 17, 2026
@oleksandr-nc
Copy link
Contributor

oleksandr-nc commented Feb 17, 2026

Maybe we can test this idea:

start_bg_task()
yield
SIGTERM_RECEIVED.set()  # Uvicorn will handle SIGTERM on it's own? https://github.com/fastapi/fastapi/issues/2928

Idea behind this:

  1. Uvicorn catches SIGTERM
  2. Uvicorn triggers lifespan shutdown
  3. Background thread finishes current task, sees the event, breaks out
  4. Process exits cleanly

This will also be a benefit for usual docker installations

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
@marcelklehr
Copy link
Member Author

Yep, from my testing, I think we need to wait for the processing to be done in the lifetime handler to avoid it shutting down prematurely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments