ported code to celery 3.1.5. Added locks to celery tasks to prevent parallel execution