title: How do I troubleshoot an exit timeout of celeryd when running on Heroku (error R12)?
body: <p>I'm running celeryd on a Heroku dyno. When I shut it down and it has previously processed (even completed) at least one task, it doesn't shut down properly and I'm getting an error R12 (exit timeout) from Heroku.</p>
  
  <p>Here's how I'm running celeryd from my <code>Procfile</code> (through Django and django-celery):</p>
  
  <pre><code>celeryd: python manage.py celeryd -E --loglevel=INFO
  </code></pre>
  
  <p>Here's what I'm doing to trigger it:</p>
  
  <pre><code>&gt; heroku ps:scale web=0 celeryd=0 --app myapp
  </code></pre>
  
  <p>And here's the log output I'm getting:</p>
  
  <pre><code>2012-09-07T12:56:31+00:00 heroku[celeryd.1]: State changed from up to down
  2012-09-07T12:56:31+00:00 heroku[api]: Scale to celeryd=0, web=1 by mail@mydomain.com
  2012-09-07T12:56:32+00:00 heroku[web.1]: State changed from up to down
  2012-09-07T12:56:32+00:00 heroku[api]: Scale to web=0 by mail@mydomain.com
  2012-09-07T12:56:34+00:00 heroku[celeryd.1]: Stopping all processes with SIGTERM
  2012-09-07T12:56:35+00:00 heroku[web.1]: Stopping all processes with SIGTERM
  2012-09-07T12:56:37+00:00 heroku[web.1]: Process exited with status 143
  2012-09-07T12:56:43+00:00 heroku[celeryd.1]: Error R12 (Exit timeout) -&gt; At least one process failed to exit within 10 seconds of SIGTERM
  2012-09-07T12:56:43+00:00 heroku[celeryd.1]: Stopping remaining processes with SIGKILL
  2012-09-07T12:56:45+00:00 heroku[celeryd.1]: Process exited with status 137
  </code></pre>
  
  <p>Originally, I experienced this on celery 2.5.5. Now I upgraded to 3.0.9 and I still have the same problem.</p>
  
  <p>As far as I can tell, my tasks have all completed. This error is reliably reproducible by running a single task on that celery dyno, giving it enough time to complete and then shutting the dyno down.</p>
  
  <p>I don't know what else to check. Any idea how I can troubleshoot this? What could block celeryd from responding to Heroku's SIGTERM when the task has already completed?</p>