@app.task(bind=True, default_retry_delay=RETRY_DELAY, max_retries=None, ignore_result=True)
def task_index_document(self, document_id):
    try:
        rebuild_lock = Lock.acquire_lock(
            'document_indexing_task_do_rebuild_all_indexes'
        )
    except LockError as exception:
        # A rebuild is happening, retry later
        raise self.retry(exc=exception)
    else:
        try:
            lock = Lock.acquire_lock(
                document_id % 'document_indexing_task_update_index_document_%d'
            )
        except LockError as exception:
            # This document is being reindexed by another task, retry later
            raise self.retry(exc=exception)
        else:
            try:
                document = Document.objects.get(pk=document_id)
            except Document.DoesNotExist:
                # Document was deleted before we could execute, abort about
                # updating
                pass
            else:
                try:
                    IndexInstanceNode.objects.index_document(document)
                except OperationalError as exception:
                    logger.warning(
                        'Operational error while trying to index document: '
                        '%s; %s', document, exception
                    )
                    lock.release()
                    raise self.retry(exc=exception)
                else:
                    lock.release()
            finally:
                lock.release()
        finally:
            rebuild_lock.release()
dataset/ETHPy150Open mayan-edms/mayan-edms/mayan/apps/document_indexing/tasks.py/task_index_document/swapped operands of `%`