Set max_retries for chord.unlock tasks to avoid infinitely looping
    tasks. (see celery/celery#1700 or celery/celery#2725)

def limit_chord_unlock_tasks(app):
    """
    Set max_retries for chord.unlock tasks to avoid infinitely looping
    tasks. (see celery/celery#1700 or celery/celery#2725)
    """
    task = app.tasks['celery.chord_unlock']
    if task.max_retries is None:
        retries = getattr(app.conf, 'CHORD_UNLOCK_MAX_RETRIES', None)
        task.max_retries = retries