Exemplo n.º 1
0
 def set_state(self, name, state):
     session = db.get_session()
     with session.begin():
         try:
             q = utils.model_query(models.ModuleStateInfo,
                                   session).filter_by(
                                       name=name, ).with_lockmode('update')
             db_state = q.one()
             db_state.state = state
         except sqlalchemy.orm.exc.NoResultFound:
             db_state = models.ModuleStateInfo(name=name, state=state)
             session.add(db_state)
     return bool(db_state.state)
Exemplo n.º 2
0
 def set_priority(self, name, priority):
     session = db.get_session()
     with session.begin():
         try:
             q = utils.model_query(models.ModuleStateInfo, session)
             q = q.filter(models.ModuleStateInfo.name == name)
             q = q.with_lockmode('update')
             db_state = q.one()
             db_state.priority = priority
         except sqlalchemy.orm.exc.NoResultFound:
             db_state = models.ModuleStateInfo(name=name, priority=priority)
             session.add(db_state)
     return int(db_state.priority)