Exemplo n.º 1
0
def child():
    print 'Child started.'
    yield bluelet.null()
    print 'Child resumed.'
    yield bluelet.null()
    print 'Child ending.'
    yield bluelet.end(42)
Exemplo n.º 2
0
    def interact(self,*argv):
        while not self.closed :
            if self.refresh:
                try:
                    data = rpc.sync('fread',self.spfd,64)
                    self.closed = data is None
                except Exception as e:
                    data ="IO ERROR 267: %s" % e
                    self.closed = True

                try:
                    if len(data):
                        eol = data.endswith('\n')
                        tmp = data.split('\n')
                        if len(self.vt):
                            data = [ self.vt.pop() + tmp.pop(0) ]
                            data.extend(tmp)

                            for tmp in data:
                                if tmp :
                                    self.vt.append( tmp )
                            if eol:
                                self.vt.append('')
                            while len(self.vt)> self.screen.height:
                                self.vt.pop(0)

                            self.screen.set_lines( self.vt )
                            #self.screen.dirty = True

                except Exception as e:
                    warn('200:',e)
                    self.closed = True
            yield bluelet.null()
        warn('294: closed',self)
Exemplo n.º 3
0
def parent():
    print 'Parent started.'
    yield bluelet.null()
    print 'Parent resumed.'
    result = yield child()
    print 'Child returned:', repr(result)
    print 'Parent ending.'
Exemplo n.º 4
0
def step(self):
    global ticks,PN

    while bluelet.threads:
        if ticks:
            print('.',file=sys.stderr,end='')
            sys.stderr.flush()
            pong = yield rpc('ping')
            assert pong=='pong'
        else:
            yield bluelet.null()
Exemplo n.º 5
0
 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()
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
def exc_child():
    yield bluelet.null()
    raise Exception()