title: How to retrieve Celery tasks that have not yet started, using Django?
body: <p>From reading the <a href="http://docs.celeryproject.org/en/latest/userguide/workers.html#dump-of-reserved-tasks" rel="nofollow">Celery documentation</a>, it looks like I should be able to use the following python code to list tasks on the queue that have not yet been picked up:</p>
  
  <pre><code>from celery.task.control import inspect
  i = inspect()
  tasks = i.reserved()
  </code></pre>
  
  <p>However, when running this code, the list of tasks is empty, even if there are items waiting in the queue (I have verified they are definitely in the queue using django-admin). The same is true for using the command line equivalent:</p>
  
  <pre><code>$ celeryctl inspect reserved
  </code></pre>
  
  <p>So I'm guessing this is not in fact what this command is for? If not, what is the accepted way to retrieve a list of tasks that have not yet started? Do I have to maintain my own list of task IDs in the code in order to query them?</p>
  
  <p>The reason I ask is because I am trying to handle a situation where two tasks are queued which perform a write operation on the same object in the database. If both tasks execute in parallel and task 1 takes longer than task 2, it will overwrite the output from task 2, but I want the output from the most recent task i.e. task 2. So my plan was to cancel any pending tasks that operate on an object each time a new task is added which will write to the same object.</p>
  
  <p>Thanks<br>
  Tom</p>