Repository navigation
Concurrency: Allow custom timeout settings #52853
Replies: 6 comments 2 replies
|
EDIT: looking into the code, I see EDIT2: it also has |
|
Unfortunately, we can't interact with this class directly when using the For example this code: [$userCount, $orderCount] = Concurrency::timeout(300)->run([
fn () => 10,
fn () => 20,
]);Throw this error:
|
|
A bit late to the party, but here is what I did: app()->bind(Illuminate\Process\Factory::class, function () {
return new class extends Illuminate\Process\Factory
{
public function newPendingProcess()
{
return parent::newPendingProcess()->forever();
}
};
});You can use this snippet at the very beginning of a controller or globally in |
|
This approach doesn't seem to work in Laravel 12 with Concurrency. Are there any plans to extend it so we can run Concurrency::timeout(123)->run() or Concurrency::forever()->run()? |
|
Yes please! Any plans on extending this? I'm currently working on trying to load a 2GB XML file into a database, and following on @christophrumpel video (he was working with csvs), but found out this could increase the speed from 1hour to around 5'. https://github.com/christophrumpel/laravel-import-million-rows/blob/main/app/Traits/ImportHelper.php But, after 60s, the process dies due to the timeout issue. Any plans on upgrading it? |
|
If you're using the default process driver you can implement what the ProcessDriver does under the hood yourself like this: <?php
use Illuminate\Console\Application;
use Illuminate\Process\Factory;
use Laravel\SerializableClosure\SerializableClosure;
$processFactory = app(Factory::class);
$command = Application::formatCommandString('invoke-serialized-closure');
$results = $processFactory->pool(function (Pool $pool) use ($tasks, $command) {
foreach ($tasks as $key => $task) {
$pool->as($key)->forever()->path(base_path())->env([
'LARAVEL_INVOKABLE_CLOSURE' => serialize(new SerializableClosure($task)),
])->command($command);
}
})->start()->wait(); |
Uh oh!
There was an error while loading. Please reload this page.
Currently, it's not possible to run tasks in
Concurrencythat take longer than 60 seconds to complete. This limitation stems from this line in the Laravel framework:https://github.com/laravel/framework/blob/11.x/src/Illuminate/Process/PendingProcess.php#L44
It would be helpful to allow custom timeouts for tasks. For example:
This way, developers could set a timeout for long-running tasks as needed.
All reactions