Add wait() method to Job Batching #52528
Unanswered
handhikadj
asked this question in
Ideas
Replies: 2 comments 3 replies
-
I don't think parallel processing should go in a controller ... If you must, you better use the sync driver without batch. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I implemented it using polling like this: protected function waitForBatch(Batch $batch, \Closure $callback, $pollSeconds = 5): void
{
while (! $batch->finished()) {
$batch = $batch->fresh();
$callback($batch);
sleep($pollSeconds);
}
} Then when calling it you can do: $this->waitForBatch($batch, function (Batch $batch) use (&$progress) {
$currentProgress = $batch->progress();
if ($currentProgress !== $progress) {
$this->info('['.now()->toDateTimeString().'] '.$batch->processedJobs().'/'.$batch->totalJobs.' '.$batch->progress().'%');
$progress = $currentProgress;
}
}); |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
currently there's no way to wait for a job batch to finish. adding
wait()
method toBatch
would be awesome. something like this:I think this will open parallel processing capability to the framework
Beta Was this translation helpful? Give feedback.
All reactions