Issue-42: Provide a safe way to halt the bulk task (2.x) #48
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
Fixes #42
This pull request introduces functionality to safely halt a bulk task and resume it later from the same position in the database. This enhancement avoids the need to let the bulk task run unnecessarily or restart from the beginning when resuming.
Description
Currently, once a bulk task begins, it processes the entire database, invoking the callable for each item. However, there is no built-in way to halt the task and resume later at the same position. This PR addresses that limitation by:
false
to signal the task to halt early.min_id
) is updated to reflect the last processed item when halting.Additionally, unnecessary parameters in test methods have been removed to simplify the codebase, and new test cases have been introduced to validate the halt-and-resume functionality.
Motivation and Context
This change is motivated by a real-world use case where a bulk task was designed to delete items from a database. The client requested the ability to stop after deleting a specific number of items to review the impact of the deletions before proceeding further. Previously, stopping the task early required letting the rest of the bulk task run unnecessarily or restarting it from the beginning, which was inefficient and error-prone.
How Has This Been Tested?
test_halt_task
, was added to ensure the bulk task can be halted and resumed correctly.Screenshots (if applicable)
N/A
Types of changes
Checklist: