Answers.Body: <p>One pitfall: In Craft 2 I've had troubles with a script that created thousands of entries.</p>
  
  <p>The CP totally hung because it could not process the numerous tasks that were created (tasks of the like 'updateUri' ..). This was probably due to time limits and memory consumption; tasks were not processed anymore.</p>
  
  <p>To solve that I created a <a href="https://straightupcraft.com/craft-plugins/taskrunner" rel="nofollow noreferrer">task runner plugin</a>, that processes a limited amount of tasks in the background through a cron job, and disables task execution on control panel access.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-11T13:38:59.493Z
Answers.Text: Great solution! Looks like a nice plugin. I'll definitely dig into it further. Thanks for the resource.
Answers.UserDisplayName: Peter Tell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-11T05:37:37.227Z
Answers.LastActivityDate: 2017-08-11T05:37:37.227Z
Answers.UserDisplayName: 24HOURSMEDIA
Body: <p>I love the notion of tasks, especially for large processes, but I've found that their isn't a lot of documentation around it which makes trouble shooting them via an authoritative source difficult.</p>
  
  <p>A few things I've found out that I had misconceptions on:</p>
  
  <ol>
  <li>A task is <em>one</em> request, no matter how many steps it has, that runs in the background.</li>
  <li>Sub tasks are all part of that initial task's one request</li>
  <li>Since a task is a single request it is subjected to the same PHP Limitations that a normal request would be (i.e., memory limit) (this really comes into play when important large amounts of data in a dev environment because there's a lot of information that's being logged via a single request -- could be 100s of MB of log files in request</li>
  </ol>
  
  <p>Some things I'm still confused about:</p>
  
  <ol>
  <li><p>Does a task run with a separate session ID and thread than the browser that initiated the task via the CP request? I've noticed using the Power Nap plugin that if I initiate the running of task via a CP request I can navigate to other pages while the task is still running, but with other plugins that import Commerce data, I have to wait until the entire import is done before I can navigate to another page.</p></li>
  <li><p>Do multiple queued tasks all get a single request or are they lumped into a single request?</p></li>
  <li><p>If I need to insert thousands of entries is it more performant / desirable to place all entries in a single task or queue a task for each entry?</p></li>
  </ol>
  
  <p>I'm sure their will be more, but I definitely think a single location for figuring out the benefits / use cases / pitfalls of Craft Tasks will be hugely beneficial.</p>
  
  <p>Thanks in advance for the discussion.</p>
  
Tags: <plugin-development>
Title: Can someone demystify tasks with a little more detail?
ThreadText: # Can someone demystify tasks with a little more detail?
  
  (Asked by: username_0 on 2017-07-18)
  
  I love the notion of tasks, especially for large processes, but I've found that their isn't a lot of documentation around it which makes trouble shooting them via an authoritative source difficult.
  
  A few things I've found out that I had misconceptions on:
  
  1. A task is *one* request, no matter how many steps it has, that runs in the background.
  2. Sub tasks are all part of that initial task's one request
  3. Since a task is a single request it is subjected to the same PHP Limitations that a normal request would be (i.e., memory limit) (this really comes into play when important large amounts of data in a dev environment because there's a lot of information that's being logged via a single request -- could be 100s of MB of log files in request
  
  Some things I'm still confused about:
  
  1. Does a task run with a separate session ID and thread than the browser that initiated the task via the CP request? I've noticed using the Power Nap plugin that if I initiate the running of task via a CP request I can navigate to other pages while the task is still running, but with other plugins that import Commerce data, I have to wait until the entire import is done before I can navigate to another page.
  2. Do multiple queued tasks all get a single request or are they lumped into a single request?
  3. If I need to insert thousands of entries is it more performant / desirable to place all entries in a single task or queue a task for each entry?
  
  I'm sure their will be more, but I definitely think a single location for figuring out the benefits / use cases / pitfalls of Craft Tasks will be hugely beneficial.
  
  Thanks in advance for the discussion.
  
  **Tags:** plugin-development
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-08-11. Score: 3
  
  One pitfall: In Craft 2 I've had troubles with a script that created thousands of entries.
  
  The CP totally hung because it could not process the numerous tasks that were created (tasks of the like 'updateUri' ..). This was probably due to time limits and memory consumption; tasks were not processed anymore.
  
  To solve that I created a [task runner plugin](https://straightupcraft.com/craft-plugins/taskrunner), that processes a limited amount of tasks in the background through a cron job, and disables task execution on control panel access.
  
  > **Comments:**
  > **username_0**: Great solution! Looks like a nice plugin. I'll definitely dig into it further. Thanks for the resource.  
  
  ---
  
  