I got this script from Celery'd github repository. My goal was to change it as little as possible while still supporting our added PULP_CONCURRENCY setting. Therefore, I'd prefer not to deviate where it is unnecessary.