Exemple #1
0
def acquire_lock(model, id, session=None):
    if b.get_driver_name() != "sqlite":
        query = _secure_query(model).filter("id = '%s'" % id)

        query.update({"updated_at": timeutils.utcnow()}, synchronize_session="fetch")
    else:
        sqlite_lock.acquire_lock(id, session)
    def _run_acquire_release_sqlite_lock(self, obj_id, session):
        self._random_sleep()

        sqlite_lock.acquire_lock(obj_id, session)

        self._random_sleep()

        sqlite_lock.release_locks(session)
Exemple #3
0
    def _run_acquire_release_sqlite_lock(self, obj_id, session):
        self._random_sleep()

        sqlite_lock.acquire_lock(obj_id, session)

        self._random_sleep()

        sqlite_lock.release_locks(session)
Exemple #4
0
def acquire_lock(model, id, session=None):
    # Expire all so all objects queried after lock is acquired
    # will be up-to-date from the DB and not from cache.
    session.expire_all()

    if b.get_driver_name() == 'sqlite':
        # In case of 'sqlite' we need to apply a manual lock.
        sqlite_lock.acquire_lock(id, session)

    return _lock_entity(model, id)
Exemple #5
0
def acquire_lock(model, id, session=None):
    # Expire all so all objects queried after lock is acquired
    # will be up-to-date from the DB and not from cache.
    session.expire_all()

    if b.get_driver_name() == 'sqlite':
        # In case of 'sqlite' we need to apply a manual lock.
        sqlite_lock.acquire_lock(id, session)

    return _lock_entity(model, id)
Exemple #6
0
def acquire_lock(model, id, session=None):
    if b.get_driver_name() != 'sqlite':
        query = _secure_query(model).filter("id = '%s'" % id)

        query.update(
            {'updated_at': timeutils.utcnow()},
            synchronize_session='fetch',
        )
    else:
        sqlite_lock.acquire_lock(id, session)
Exemple #7
0
def acquire_lock(model, id, session=None):
    # Expire all so all objects queried after lock is acquired
    # will be up-to-date from the DB and not from cache.
    session.expire_all()

    if b.get_driver_name() != 'sqlite':
        entity = _get_one_entity(model, id)
        entity.update({'updated_at': timeutils.utcnow()})

    else:
        sqlite_lock.acquire_lock(id, session)
        entity = _get_one_entity(model, id)

    return entity
Exemple #8
0
def acquire_lock(model, id, session=None):
    # Expire all so all objects queried after lock is acquired
    # will be up-to-date from the DB and not from cache.
    session.expire_all()

    if b.get_driver_name() != 'sqlite':
        entity = _get_one_entity(model, id)
        entity.update({'updated_at': timeutils.utcnow()})

    else:
        sqlite_lock.acquire_lock(id, session)
        entity = _get_one_entity(model, id)

    return entity