When $maxTaskPayloadInBytes is greater than 100000 (by default), the \Spatie\Async\Runtime\ParentRuntime::encodeTask function creates a temporary file in the /tmp directory.
if (strlen($serializedTask) > $maxTaskPayloadInBytes) {
// Write the serialized task to a temporary file and package it as a `FileTask`:
$filename = tempnam(sys_get_temp_dir(), 'spatie_async_task_');
file_put_contents($filename, $serializedTask);
$file_task = new FileTask($filename);
$serializedTask = base64_encode(serialize($file_task));
}
However, this function is called twice, resulting in two temporary files being created. At the end of the process, only one of these files is removed, leaving the other as a lingering temporary file.
The \VXM\Async\Runtime\ParentRuntime::createProcess method calls its parent method \Spatie\Async\Runtime\ParentRuntime::createProcess. Is there a specific reason for this? With this approach, everything looks to work fine
public static function createProcess($task, ?int $outputLength = null, ?string $binary = 'php', ?int $max_input_size = 100000): Runnable
{
if (! self::$isInitialised) {
self::init();
}
if (! Pool::isSupported()) {
return SynchronousProcess::create($task, self::getId());
}
$process = new Process([
$binary,
static::$childProcessScript,
static::$autoloader,
static::encodeTask($task),
$outputLength,
base_path(),
]);
return ParallelProcess::create($process, self::getId());
}
When
$maxTaskPayloadInBytes
is greater than 100000 (by default), the\Spatie\Async\Runtime\ParentRuntime::encodeTask
function creates a temporary file in the/tmp
directory.However, this function is called twice, resulting in two temporary files being created. At the end of the process, only one of these files is removed, leaving the other as a lingering temporary file.
The
\VXM\Async\Runtime\ParentRuntime::createProcess
method calls its parent method\Spatie\Async\Runtime\ParentRuntime::createProcess
. Is there a specific reason for this? With this approach, everything looks to work fine