Fix race condition that made it possible to N jobs to start simultaneously

That also fixed the sporadic "Getting packages..." message upon creation of a new project with some Bower or Pub packages (more pronounced for Bower, because project templates that have Pub dependencies have very few of them).
Simplify recursion from X->Y->X to X->X
Merge pull request #2675 from ussuri/fix-jobs-running-simultaneously

Fix race condition that made it possible for N jobs to start simultaneously