botnet/worker.py
def task_runner(self):
        """\
        Run tasks in a greenlet, pulling from the workers' task queue and
        reporting results to the command channel
        """
        while 1:
            (task_id, command) = self.task_queue.get()
            
            for pattern, callback in self.task_patterns:
                match = re.match(pattern, command)
                if match:
                    # execute the callback
                    ret = callback(**match.groupdict()) or ''
                    
                    # clear the stop flag in the event it was set
                    self.stop_flag.clear()
                    
                    # send output of command to channel
                    for line in ret.splitlines():
                        self.respond('!task-data %s:%s' % (task_id, line), self.channel)
                        gevent.sleep(.34)
            
            # indicate task is complete
            self.respond('!task-finished %s' % task_id, self.channel)
def task_runner(self):
        """\
        Run tasks in a greenlet, pulling from the workers' task queue and
        reporting results to the command channel
        """
        while 1:
            (task_id, command) = self.task_queue.get()
            
            for pattern, callback in self.task_patterns:
                match = re.match(pattern, command)
                if match:
                    # execute the callback
                    ret = callback(**match.groupdict()) or ''
                    
                    # clear the stop flag in the event it was set
                    self.stop_flag.clear()
                    
                    # send output of command to channel
                    for line in ret.splitlines():
                        self.respond('!task-data %s:%s' % (task_id, line), self.channel)
                        gevent.sleep(.34)
            
            # indicate task is complete
            self.respond('!task-finished %s' % task_id, self.channel)
\
        Run tasks in a greenlet, pulling from the workers' task queue and
        reporting results to the command channel