This whole function should not be run if this is being called synchronously. I'm not sure exactly how to determine that, but there are some possibilities like checking the task context. http://docs.celeryproject.org/en/latest/userguide/tasks.html#context