What is the meaning of bind = True keyword in celery?

Just a small addition to other answers. As already stated, bound tasks have access to the task instance. One use case when this is needed are retries:

@celery.task(bind=True, max_retries=5)
def retrying(self):
    try:
        return 1/0
    except Exception:
        self.retry(countdown=5)

Another use case is when you want to define custom states for your tasks and be able to set it during task execution:

@celery.task(bind=True)
def show_progress(self, n):
    for i in range(n):
        self.update_state(state="PROGRESS", meta={'current': i, 'total': n})

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)