Fix/371 repeat every task lifecycle#372
Open
Binilkks wants to merge 2 commits intofastapiutils:masterfrom
Open
Fix/371 repeat every task lifecycle#372Binilkks wants to merge 2 commits intofastapiutils:masterfrom
Binilkks wants to merge 2 commits intofastapiutils:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses issue #371 by improving lifecycle management for repeated background tasks created by
repeat_every.Previously,
repeat_everystarted tasks in the background without exposing a task handle, which made it hard to inspect or cancel running tasks during shutdown/reload scenarios.What Changed
ensure_futuretocreate_taskin fastapi_utils/tasks.py.get_repeated_task(task_func): returns the active task handle (orNone)cancel_repeated_task(task_func): cancels active task and returns success statusWhy
This provides a safer lifecycle path for long-running services:
Behavior Impact
repeat_everyusage remains compatible.seconds,wait_first,max_repetitions,on_exception,on_complete) is unchanged.Testing
Related
Closes #371