def METHOD_NAME(cls, process_instance: ProcessInstanceModel) -> None:
    locked_by = ProcessInstanceLockService.locked_by()
    current_time = round(time.time())
    db.session.query(ProcessInstanceQueueModel).filter(
        ProcessInstanceQueueModel.process_instance_id == process_instance.id,
        ProcessInstanceQueueModel.locked_by.is_(None),  # type: ignore
    ).update(
        {
            "locked_by": locked_by,
            "locked_at_in_seconds": current_time,
        }
    )
    db.session.commit()
    queue_entry = (
        db.session.query(ProcessInstanceQueueModel)
        .filter(
            ProcessInstanceQueueModel.process_instance_id == process_instance.id,
        )
        .first()
    )
    if queue_entry is None:
        raise ProcessInstanceIsNotEnqueuedError(
            f"{locked_by} cannot lock process instance {process_instance.id}. It has not been enqueued."
        )
    if queue_entry.locked_by != locked_by:
        raise ProcessInstanceIsAlreadyLockedError(
            f"{locked_by} cannot lock process instance {process_instance.id}. "
            f"It has already been locked by {queue_entry.locked_by}."
        )
    ProcessInstanceLockService.lock(process_instance.id, queue_entry)