Exemplo n.º 1
0
 def qdel(self,jid):
     """delete job jid from the queue"""
     #try:
     db = DAL(config.uri, auto_import=True, migrate=False, 
              folder=config.dbdir)
     del db.jobs[jid]
     db.commit()
     db.close()
Exemplo n.º 2
0
 def _set_state(self,jid,state):
     """update state of job"""
     self.mutex.acquire()
     db = DAL(config.uri, auto_import=True, migrate=False, folder=config.dbdir)
     db.jobs[jid] = dict(state=state)
     db.commit()
     db.close()
     self.mutex.release()
Exemplo n.º 3
0
 def qsub(self,app,cid,user,np,pry,desc=""):
     """queue job ... really just set state to 'Q'."""
     db = DAL(config.uri, auto_import=True, migrate=False, 
              folder=config.dbdir)
     jid = db.jobs.insert(user=user, app=app, cid=cid, state=STATE_QUEUED, 
                           description=desc, time_submit=time.asctime(), np=np, priority=pry)
     db.commit()
     db.close()
     return str(jid)
Exemplo n.º 4
0
 def qfront(self):
     """pop the top job off of the queue that is in a queued 'Q' state"""
     db = DAL(config.uri, auto_import=True, migrate=False, folder=config.dbdir)
     myorder = db.jobs.priority
     #myorder = db.jobs.priority | db.jobs.id
     row = db(db.jobs.state==STATE_QUEUED).select(orderby=myorder).first()
     db.close()
     if row: return row.id
     else: return None
Exemplo n.º 5
0
    def stop_expired_jobs(self):
        """shutdown jobs that exceed their time limit"""
        db = DAL(config.uri, auto_import=True, migrate=False, folder=config.dbdir)
        rows = db(db.jobs.state==STATE_RUN).select()
        for row in rows:
            if row:
                walltime = int(row.walltime)
                time_submit = time.mktime(datetime.datetime.strptime(
                              row.time_submit, "%a %b %d %H:%M:%S %Y").timetuple())
                now = time.mktime(datetime.datetime.now().timetuple())
                runtime = now - time_submit
                if runtime > walltime:
                    print "INFO: scheduler stopped job", row.id, "REASON: reached timeout"
                    self.stop(row.id)

        db.close()
Exemplo n.º 6
0
 def qstat(self):
     """return the number of jobs in a queued 'Q' state"""
     db = DAL(config.uri, auto_import=True, migrate=False, 
              folder=config.dbdir)
     return db(db.jobs.state==STATE_QUEUED).count()
     db.close()