You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Repeated background task has no lifecycle handle/cancel path (orphan task risk) #371
Describe the bug
The repeat_every scheduler starts a background task but does not keep or expose the created task handle.
Because of this, consumers cannot explicitly cancel/inspect the repeating task during shutdown/reload, which can cause lifecycle-management issues in long-running apps.
No direct traceback is produced in normal cases because this is primarily a lifecycle/control bug, not an immediate exception bug.
To Reproduce
Create a FastAPI app and define a startup task using repeat_every.
Use a short interval (for example 1 second) and log each execution.
Start the app, then trigger shutdown/reload (or restart worker process).
Observe that task lifecycle is not explicitly controllable by library API (no returned handle to cancel/manage).
Example app:
`from fastapi import FastAPI
from fastapi_utils.tasks import repeat_every
import logging
Expected behavior
repeat_every should provide a lifecycle-safe path to track and cancel the created background task (directly or via documented shutdown hook support), so periodic jobs can be cleanly managed during app shutdown/reload.
Screenshots
If applicable, add screenshots to help explain your problem.
Activity