opdemand/deis — pull request #359 by gabrtv (2013-12-04 22:56:11+00:00)
Title: Fix Celery deadlocks by removing all blocking tasks from parent tasks

After discussing the issue at length with the helpful folks on IRC, it was confirmed that the upgrade to Celery 3.1.x made this problem much worse for us as "the pool prefetching will (now) write the tasks to the same process that is waiting".

Celery best practice is to not call blocking tasks within other tasks or risk resource starvation and deadlocking, see:
http://docs.celeryproject.org/en/latest/userguide/tasks.html#avoid-launching-synchronous-subtasks

This PR moves much of the blocking subtasks into the model methods. It has the added benefit of simplifying view/task code with a net decrease in total lines of code. While it's possible this introduced a regression, I did heavy testing with a pool of 1.