def start(self,jid): """start running a job by creating a new process""" global p, jobs myjobs = [] db = DAL(config.uri, auto_import=True, migrate=False, folder=config.dbdir) user = db.jobs(jid).user app = db.jobs(jid).app cid = db.jobs(jid).cid np = db.jobs(jid).np if np > 1: # use mpi command = db.apps(name=app).command command = config.mpirun + " -np " + str(np) + " " + command else: # dont use mpi command = db.apps(name=app).command exe = os.path.join(config.apps_dir,app,app) outfn = app + ".out" cmd = command + ' >& ' + outfn run_dir = os.path.join(config.user_dir,user,app,cid) # if number procs available fork new process with command for i in range(np): self.sem.acquire() p = Process(target=self.start_job, args=(run_dir,cmd,app,jid,np,)) myjobs.append(p) print len(myjobs), myjobs p.start() for i in range(np): self.sem.release()
def start(self,jid): """start running a job by creating a new process""" db = DAL(config.uri, auto_import=True, migrate=False, folder=config.dbdir) uid = db.jobs(jid).uid user = db.users(uid).user app = db.jobs(jid).app cid = db.jobs(jid).cid np = db.jobs(jid).np if np > 1: # use mpi command = db.jobs(jid).command command = config.mpirun + " -np " + str(np) + " " + command else: # dont use mpi command = db.jobs(jid).command # redirect output to appname.out file outfn = app + ".out" cmd = command + ' > ' + outfn + ' 2>&1 ' print "cmd:", cmd run_dir = os.path.join(user_dir, user, app, cid) # if number procs available fork new process with command for i in range(np): self.sem.acquire() p = Process(target=self.start_job, args=(run_dir,cmd,app,jid,np,myjobs)) p.start() for i in range(np): self.sem.release()