As noted above, the lock is released before the task is requeued.  So no task should be in the queue because of a retry and be locked.  If that were the case, it would fail when the retry is run.  The purpose of the lock is to prevent the same task from being run twice (or more) at the same time.  We also check the status of the task to see if it has already been run.  These deal with the same task being queued twice by celery.  Nothing in this locking deals with other tasks, as you correctly note.