Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/daemon/workers/PhabricatorWorker.php
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | final public static function scheduleTask( | ||||
$object_phid = idx($options, 'objectPHID'); | $object_phid = idx($options, 'objectPHID'); | ||||
$task = id(new PhabricatorWorkerActiveTask()) | $task = id(new PhabricatorWorkerActiveTask()) | ||||
->setTaskClass($task_class) | ->setTaskClass($task_class) | ||||
->setData($data) | ->setData($data) | ||||
->setPriority($priority) | ->setPriority($priority) | ||||
->setObjectPHID($object_phid); | ->setObjectPHID($object_phid); | ||||
$delay = idx($options, 'delayUntil'); | |||||
if ($delay) { | |||||
$task->setLeaseExpires($delay); | |||||
artms: If queue is empty and this is the only task into the queue - it will be immediately executed… | |||||
} | |||||
if (self::$runAllTasksInProcess) { | if (self::$runAllTasksInProcess) { | ||||
// Do the work in-process. | // Do the work in-process. | ||||
$worker = newv($task_class, array($data)); | $worker = newv($task_class, array($data)); | ||||
while (true) { | while (true) { | ||||
try { | try { | ||||
$worker->doWork(); | $worker->doWork(); | ||||
foreach ($worker->getQueuedTasks() as $queued_task) { | foreach ($worker->getQueuedTasks() as $queued_task) { | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |
If queue is empty and this is the only task into the queue - it will be immediately executed - is this expected behavior?
By default PhabricatorWorkerLeaseQuery fetches unleased tasks which are leaseOwner IS NULL (https://secure.phabricator.com/source/phabricator/browse/master/src/infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php$226), so setting leaseExpire without setting leaseOwner looks like not to yield any delay at all...