Answers.Body: <p>Before you push the job to the queue you can specify the <code>ttr</code> (time to reserve) in order to prevent the job being cancelled after 300 seconds (the default).</p>
  
  <pre><code>Craft::$app-&gt;queue-&gt;ttr(3600);
  Craft::$app-&gt;queue-&gt;push($myJob);
  </code></pre>
  
  <p>Alternatively, you can make your Job class implement <code>RetryableJobInterface</code> and then give it its own <code>getTtr()</code> method. 
  See the <a href="https://github.com/yiisoft/yii2-queue/blob/master/docs/guide/retryable.md#retryablejobinterface" rel="nofollow noreferrer">docs that explain this</a>.</p>
  
  <pre><code>class SomeJob extends \craft\queue\BaseJob implements RetryableJobInterface
  {
      public function getTtr()
      {
          return 3600;
      }
  }
  </code></pre>
  
  <p>Or via configuration <code>config/app.php</code>:</p>
  
  <pre><code>return [
      'components' =&gt; [
          'queue' =&gt; [
              'ttr' =&gt; 600,
          ],
      ],
  ];
  </code></pre>
  
  <p>Finally, you can also achieve this using the provided <a href="https://github.com/yiisoft/yii2-queue/blob/master/docs/guide/retryable.md#event-handlers" rel="nofollow noreferrer">event handlers</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-24T18:24:05.640Z
Answers.Text: Thank you. I think Brandon's method here is slightly cleaner: https://github.com/craftcms/cms/issues/3147#issuecomment-407475927
Answers.UserDisplayName: benface
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-25T07:54:48.697Z
Answers.Text: Agreed, I've updated the answer to match.
Answers.UserDisplayName: Ben Croker
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-04-03T20:57:22.433Z
Answers.LastActivityDate: 2019-03-25T07:54:27.373Z
Answers.LastEditDate: 2019-03-25T07:54:27.373Z
Answers.UserDisplayName: Ben Croker
Body: <p>Please see the attached screenshot. On heavy tasks the queue is cancelled. Where do I set the timeout or remove it completely?
  <a href="https://i.sstatic.net/fzDoy.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/fzDoy.png" alt="Screenshot"></a></p>
  
Tags: <tasks><stalled-tasks>
Title: Queue Exec Time
ThreadText: # Queue Exec Time
  
  (Asked by: username_0 on 2018-04-02)
  
  Please see the attached screenshot. On heavy tasks the queue is cancelled. Where do I set the timeout or remove it completely?
  [![Screenshot](https://i.sstatic.net/fzDoy.png)](https://i.sstatic.net/fzDoy.png)
  
  **Tags:** tasks, stalled-tasks
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-04-03. Score: 5 | Accepted answer
  
  Before you push the job to the queue you can specify the `ttr` (time to reserve) in order to prevent the job being cancelled after 300 seconds (the default).
  
  ```
  Craft::$app->queue->ttr(3600);
  Craft::$app->queue->push($myJob);
  
  ```
  
  Alternatively, you can make your Job class implement `RetryableJobInterface` and then give it its own `getTtr()` method.
  See the [docs that explain this](https://github.com/yiisoft/yii2-queue/blob/master/docs/guide/retryable.md#retryablejobinterface).
  
  ```
  class SomeJob extends \craft\queue\BaseJob implements RetryableJobInterface
  {
      public function getTtr()
      {
          return 3600;
      }
  }
  
  ```
  
  Or via configuration `config/app.php`:
  
  ```
  return [
      'components' => [
          'queue' => [
              'ttr' => 600,
          ],
      ],
  ];
  
  ```
  
  Finally, you can also achieve this using the provided [event handlers](https://github.com/yiisoft/yii2-queue/blob/master/docs/guide/retryable.md#event-handlers).
  
  > **Comments:**
  > **username_2**: Thank you. I think Brandon's method here is slightly cleaner: https://github.com/craftcms/cms/issues/3147#issuecomment-407475927  
  > **username_1**: Agreed, I've updated the answer to match.  
  
  ---
  
  