Uh oh!
There was an error while loading. Please reload this page.
fix(tasks): avoid dropping completed task results during collection - #639
Conversation
| /// Collect completed results from running tasks and remove them from the running tasks map. | ||
| pub fn collect_completed_results(&mut self) -> Vec<TaskResult> { | ||
| pub fn collect_completed_results(&mut self) { |
There was a problem hiding this comment.
thoughts on this being pub in the first place?
There was a problem hiding this comment.
Right now, the function has to be public because it is called from the output of #[task_handler] macro.
However, it would make sense to make this private and have OperationProcessor::peek_completed and OperationProcessor::take_completed_result call this before returning. Do you think that would be better?
There was a problem hiding this comment.
Yes, something like that makes sense to me. Can you make the change?
There was a problem hiding this comment.
Pushed the change.
One thing that is slightly awkward is that peek_completed (and a few other functions whose names suggest non-mutating behavior) now requires &mut self. I think it is fine, but it could be slightly confusing.
Also, while I was doing that I realized that task_result_receiver has no real reason to be an Option (The channel is initialized on startup and not set again) and made it required.
Uh oh!
There was an error while loading. Please reload this page.
Remove the
std::mem::takefromOperationProcessor::collect_completed_resultsMotivation and Context
std::mem::takewould clearOperationProcessor::completed_results, causing completed tasks to be dropped. This madetasks/getandtasks/resultto fail for subsequent requests.How Has This Been Tested?
Breaking Changes
This is technically a breaking change that changes the return type of
OperationProcessor::collect_completed_resultsfromVec<TaskResult>to(). However, I doubt there was anyone calling the method directly without using the#[tool_handler]macro.I did this to avoid introducing an unnecessary
clonecall. If this is a problem, I can change the method so it returns either:self.completed_results.clone()Types of changes
Checklist
Additional context
Fixes#638