Simplified the code
This commit is contained in:
parent
f9152ce140
commit
069786cd7f
1 changed files with 23 additions and 29 deletions
|
@ -943,8 +943,7 @@ class Worker
|
||||||
|
|
||||||
if (DI::config()->get('system', 'worker_multiple_fetch')) {
|
if (DI::config()->get('system', 'worker_multiple_fetch')) {
|
||||||
$pids = [];
|
$pids = [];
|
||||||
$worker_pids = self::getWorkerPIDList();
|
foreach (self::getWorkerPIDList() as $pid => $count) {
|
||||||
foreach ($worker_pids as $pid => $count) {
|
|
||||||
if ($count <= $fetch_limit) {
|
if ($count <= $fetch_limit) {
|
||||||
$pids[] = $pid;
|
$pids[] = $pid;
|
||||||
}
|
}
|
||||||
|
@ -979,7 +978,11 @@ class Worker
|
||||||
DBA::close($tasks);
|
DBA::close($tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($ids)) {
|
if (empty($ids)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign the task ids to the workers
|
||||||
$worker = [];
|
$worker = [];
|
||||||
foreach (array_unique($ids) as $id) {
|
foreach (array_unique($ids) as $id) {
|
||||||
$pid = next($pids);
|
$pid = next($pids);
|
||||||
|
@ -999,9 +1002,6 @@ class Worker
|
||||||
self::$db_duration_write += (microtime(true) - $stamp);
|
self::$db_duration_write += (microtime(true) - $stamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return !empty($ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the next worker process
|
* Returns the next worker process
|
||||||
*
|
*
|
||||||
|
@ -1022,17 +1022,11 @@ class Worker
|
||||||
}
|
}
|
||||||
self::$lock_duration += (microtime(true) - $stamp);
|
self::$lock_duration += (microtime(true) - $stamp);
|
||||||
|
|
||||||
$found = self::findWorkerProcesses();
|
self::findWorkerProcesses();
|
||||||
|
|
||||||
DI::lock()->release(self::LOCK_PROCESS);
|
DI::lock()->release(self::LOCK_PROCESS);
|
||||||
|
|
||||||
if ($found) {
|
return self::getWaitingJobForPID();
|
||||||
$stamp = (float)microtime(true);
|
|
||||||
$r = DBA::select('workerqueue', [], ['pid' => getmypid(), 'done' => false]);
|
|
||||||
self::$db_duration += (microtime(true) - $stamp);
|
|
||||||
return DBA::toArray($r);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue