コード例 #1
0
 def run(self):
     """Send a greeting to the client and begin processing commands
     as they arrive.
     """
     yield self.send(HELLO)
     
     clist = None # Initially, no command list is being constructed.
     while True:
         line = (yield self.sock.readline()).strip()
         if not line:
             break
         log.debug(line)
            
         if clist is not None:
             # Command list already opened.
             if line == CLIST_END:
                 yield bluelet.call(self.do_command(clist))
                 clist = None # Clear the command list.
             else:
                 clist.append(Command(line))
         
         elif line == CLIST_BEGIN or line == CLIST_VERBOSE_BEGIN:
             # Begin a command list.
             clist = CommandList([], line == CLIST_VERBOSE_BEGIN)
             
         else:
             # Ordinary command.
             try:
                 yield bluelet.call(self.do_command(Command(line)))
             except BPDClose:
                 # Command indicates that the conn should close.
                 self.sock.close()
                 return
コード例 #2
0
ファイル: __init__.py プロジェクト: sporkexec/beets
 def run(self):
     """Send a greeting to the client and begin processing commands
     as they arrive.
     """
     yield self.send(HELLO)
     
     clist = None # Initially, no command list is being constructed.
     while True:
         line = (yield self.sock.readline()).strip()
         if not line:
             break
         log.debug(line)
            
         if clist is not None:
             # Command list already opened.
             if line == CLIST_END:
                 yield bluelet.call(self.do_command(clist))
                 clist = None # Clear the command list.
             else:
                 clist.append(Command(line))
         
         elif line == CLIST_BEGIN or line == CLIST_VERBOSE_BEGIN:
             # Begin a command list.
             clist = CommandList([], line == CLIST_VERBOSE_BEGIN)
             
         else:
             # Ordinary command.
             try:
                 yield bluelet.call(self.do_command(Command(line)))
             except BPDClose:
                 # Command indicates that the conn should close.
                 self.sock.close()
                 return
コード例 #3
0
ファイル: __init__.py プロジェクト: sporkexec/beets
 def do_command(self, command):
     """A coroutine that runs the given command and sends an
     appropriate response."""
     try:
         yield bluelet.call(command.run(self))
     except BPDError, e:
         # Send the error.
         yield self.send(e.response())
コード例 #4
0
 def do_command(self, command):
     """A coroutine that runs the given command and sends an
     appropriate response."""
     try:
         yield bluelet.call(command.run(self))
     except BPDError, e:
         # Send the error.
         yield self.send(e.response())
コード例 #5
0
ファイル: __init__.py プロジェクト: sporkexec/beets
    def run(self, conn):
        """Coroutine executing all the commands in this list.
        """
        for i, command in enumerate(self):
            try:
                yield bluelet.call(command.run(conn))
            except BPDError, e:
                # If the command failed, stop executing.
                e.index = i # Give the error the correct index.
                raise e

            # Otherwise, possibly send the output delimeter if we're in a
            # verbose ("OK") command list.
            if self.verbose:
                yield conn.send(RESP_CLIST_VERBOSE)
コード例 #6
0
    def run(self, conn):
        """Coroutine executing all the commands in this list.
        """
        for i, command in enumerate(self):
            try:
                yield bluelet.call(command.run(conn))
            except BPDError, e:
                # If the command failed, stop executing.
                e.index = i # Give the error the correct index.
                raise e

            # Otherwise, possibly send the output delimeter if we're in a
            # verbose ("OK") command list.
            if self.verbose:
                yield conn.send(RESP_CLIST_VERBOSE)
コード例 #7
0
ファイル: Bck.py プロジェクト: liquid-phynix/hydra
    def schedule_job(self):
        unlucky = self.engines_idle.pop()
        self.engines_executing.append(unlucky)
        _,lucky = self.jobs_idle.popitem()
        lucky.engine_id = unlucky.id # assignment must happen before reinsertion
        self.jobs_executing[lucky.id] = lucky
        yield bluelet.call(unlucky.start_job(lucky.id))

        #        print('job finished: %s' % ('\n'.join(self.jobs_executing[lucky.id].output_queue)))
        self.jobs_finished[lucky.id] = self.jobs_executing[lucky.id]
        #        print('job finished: %s' % ('\n'.join(self.jobs_finished[lucky.id].output_queue)))
        del self.jobs_executing[lucky.id]
        unlucky.executing_job = None
        self.engines_executing.remove(unlucky)
        self.engines_idle.append(unlucky)
        yield bluelet.end()
コード例 #8
0
ファイル: Bck.py プロジェクト: liquid-phynix/hydra
 def app(self):
     print('client: %d engines, with id\'s %s are up' % (len(self.client.ids), self.client.ids))       
     for engine in self.engines_idle: print('id %d on %s' % (engine.id, engine.hostname))
     self.pipe.send(Ready('all systems are a go'))
     yield bluelet.call(self.scheduler())