def child(): print 'Child started.' yield bluelet.null() print 'Child resumed.' yield bluelet.null() print 'Child ending.' yield bluelet.end(42)
def parent(): print 'Parent started.' yield bluelet.null() print 'Parent resumed.' result = yield child() print 'Child returned:', repr(result) print 'Parent ending.'
def scheduler(self): while self.run: if not self.pipe.poll(): yield bluelet.null() if self.run_scheduling: if len(self.engines_idle) > 0 and len(self.jobs_idle) > 0: yield bluelet.spawn(self.schedule_job()) else: recv = self.pipe.recv() BCK.__dict__[recv[0]](self, *recv[1:]) yield bluelet.end()
def start_job(self, id): job = self.jobs_executing[id] self.apply(BCK.start_job, job.command % {'GPUID' : self.gpuid}, job.working_dir, job.unique_dir) while True: async = self.apply_async(BCK.remote_command, 'relay_stdout') while not async.ready(): yield bluelet.null() poll_code, stdout_line = async.result line = stdout_line.strip().decode() job = self.jobs_executing[id] job.output_queue.append(line) self.jobs_executing[id] = job if _pager_queue.id == id: _pager_queue.put(line) if poll_code is not None: job = self.jobs_executing[id] job.unset_executing() self.jobs_executing[id] = job break
def exc_child(): yield bluelet.null() raise Exception()