Example #1
0
 /**
  * @see QueueInterface::push()
  */
 public function push(TaskInterface $task)
 {
     try {
         $this->queue->push($task);
     } catch (\Exception $e) {
         $this->logger->err(sprintf('Unable to push task %s: %s.', $task, $e->getMessage()));
         throw $e;
     }
     $this->logger->debug(sprintf('Task %s was successfully pushed.', $task));
 }
Example #2
0
 public function shutdown()
 {
     if (!$this->currentTask) {
         return;
     }
     if ($err = error_get_last()) {
         $this->logger->err(sprintf('Worker died while working on task %s. Last error "%s" occurred in %s on line %d.', $this->currentTask, $err['message'], $err['file'], $err['line']));
     }
     if (!$this->isCurrentTaskProcessed) {
         if ($this->currentTask->reschedule()) {
             $this->currentQueue->push($this->currentTask);
         } else {
             $this->logger->err(sprintf('Task %s failed.', $this->currentTask));
         }
     }
 }