@classmethod
    def lock_for_update(cls, iterable):
        use_iterable = iterable or cls.all()
        if cls._is_query(use_iterable):
            return use_iterable.with_lockmode('update')
        elif cls._is_iterable(use_iterable):
            # we can't lock abstract iterable, so returning as is
            # for compatibility
            return use_iterable
        else:
            raise TypeError("First argument should be iterable")
Use SELECT FOR UPDATE on a given iterable (query).
dataset/ETHPy150Open openstack/fuel-web/nailgun/nailgun/objects/base.py/NailgunCollection.lock_for_update