当前位置: 首页>>代码示例>>Python>>正文


Python Dispatcher.start方法代码示例

本文整理汇总了Python中dispatcher.Dispatcher.start方法的典型用法代码示例。如果您正苦于以下问题:Python Dispatcher.start方法的具体用法?Python Dispatcher.start怎么用?Python Dispatcher.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dispatcher.Dispatcher的用法示例。


在下文中一共展示了Dispatcher.start方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Stage

# 需要导入模块: from dispatcher import Dispatcher [as 别名]
# 或者: from dispatcher.Dispatcher import start [as 别名]
class Stage():
    """
    A stage is a segment in a pipeline defining the type of workers it employs.
    """

    def __init__(self, name, WorkerClass, num_workers, in_buffer,
                 out_buffer, seq_number, pipeline, path):
        self.name = name
        self.WorkerClass = WorkerClass
        self.num_workers = num_workers
        self.pipeline = pipeline
        self.input = in_buffer
        self.output = out_buffer
        self.seq_number = seq_number
        self.worker_environ = dict(pool=self, path=path)
        self.isactive = False
        self.progress = 0

    def _create_worker(self, num):
        return [ self.WorkerClass(self.input, self.output, i, **self.worker_environ) for i in range(num) ]

    def add_worker(self):
        new_worker = self._create_worker(1)
        self.workers.append(new_worker)
        self.num_workers += 1

    def remove_worker(self):
        self.workers.pop().join()
        self.num_woker -= 1

    def start(self):
        # Global activity flag
        self.isactive = True
        # Dispatcher-controlled Event worker threads wait for before they start
        self.wakeSignal = threading.Event()
        # create worker threads
        self.workers = self._create_worker(self.num_workers)
        # create dispatcher thread
        self.dispatcher = Dispatcher(self)
        # start threads
        [worker.start() for worker in self.workers]
        # start dispatcher thread
        self.dispatcher.start()

    def stop(self):
        """
        Block until all workers have finished current job. Input queue does not
        have to be empty.
        """
        self.isactive = False
        self.dispatcher.join()

    def join(self):
        """
        Block until the input queue is empty.    
        """
        self.input.join()
        self.isactive = False
        self.dispatcher.join()
开发者ID:irvpriddy,项目名称:picture_clerk,代码行数:61,代码来源:stage.py

示例2: start_flask

# 需要导入模块: from dispatcher import Dispatcher [as 别名]
# 或者: from dispatcher.Dispatcher import start [as 别名]
def start_flask():
    global  job_queue
    global  dispatcher
    # Create IN job queue & job dispatcher
    job_queue = Queue()
    #d = Dispatcher(job_queue=job_queue, log_queue=loggingqueue.queue) Process based logging
    dispatcher = Dispatcher(job_queue=job_queue)
    dispatcher.start()
    app.run(debug=True, use_reloader=False)
开发者ID:jbfuzier,项目名称:fileanalyzer,代码行数:11,代码来源:flaskserver.py

示例3: start

# 需要导入模块: from dispatcher import Dispatcher [as 别名]
# 或者: from dispatcher.Dispatcher import start [as 别名]
def start():
    global dispatcher
    if dispatcher.isAlive():
        logging.warning("Cannot start dispatcher : Dispatcher is already running")
        return "Cannot start dispatcher : Dispatcher is already running"
    else:
        dispatcher = Dispatcher(job_queue=job_queue)
        dispatcher.start()
        return "Dispatcher started... %s" % dispatcher
开发者ID:jbfuzier,项目名称:fileanalyzer,代码行数:11,代码来源:flaskserver.py

示例4: main_loop_parallel

# 需要导入模块: from dispatcher import Dispatcher [as 别名]
# 或者: from dispatcher.Dispatcher import start [as 别名]
def main_loop_parallel():
    color_stdout("Started {0}\n".format(" ".join(sys.argv)), schema='tr_text')

    jobs = lib.Options().args.jobs
    if jobs < 1:
        # faster result I got was with 2 * cpu_count
        jobs = 2 * multiprocessing.cpu_count()

    if jobs > 0:
        color_stdout("Running in parallel with %d workers\n\n" % jobs,
                     schema='tr_text')
    randomize = True

    task_groups = lib.worker.get_task_groups()
    if lib.Options().args.reproduce:
        task_groups = lib.worker.reproduce_task_groups(task_groups)
        jobs = 1
        randomize = False

    dispatcher = Dispatcher(task_groups, jobs, randomize)
    dispatcher.start()

    lib.worker.print_greetings()

    color_stdout("\n", '=' * 86, "\n", schema='separator')
    color_stdout("WORKR".ljust(6),     schema='t_name')
    color_stdout("TEST".ljust(48),     schema='t_name')
    color_stdout("PARAMS".ljust(16),   schema='test_var')
    color_stdout("RESULT\n",           schema='test_pass')
    color_stdout('-' * 81, "\n",       schema='separator')

    try:
        is_force = lib.Options().args.is_force
        dispatcher.wait()
        dispatcher.wait_processes()
        color_stdout('-' * 81, "\n", schema='separator')
        has_failed = dispatcher.statistics.print_statistics()
        has_undone = dispatcher.report_undone(verbose=True)
        if has_failed:
            return EXIT_FAILED_TEST
        if has_undone:
            return EXIT_NOTDONE_TEST
    except KeyboardInterrupt:
        color_stdout('-' * 81, "\n", schema='separator')
        dispatcher.statistics.print_statistics()
        dispatcher.report_undone(verbose=False)
        raise
    except HangError:
        color_stdout('-' * 81, "\n", schema='separator')
        dispatcher.statistics.print_statistics()
        dispatcher.report_undone(verbose=True)
        return EXIT_HANG
    return EXIT_SUCCESS
开发者ID:tarantool,项目名称:test-run,代码行数:55,代码来源:test-run.py

示例5: __init__

# 需要导入模块: from dispatcher import Dispatcher [as 别名]
# 或者: from dispatcher.Dispatcher import start [as 别名]
class IA:
    def __init__(self, name, **kargs):
        
        # Initialisation du logger
        self.logger = getLogger("ia")
        f=open(name+".ini")
        fileConfig(f)
        f.close()

        self.logger.info("Starting  %s  robot" % name)
        assert(name in ["petit", "gros"])
        
        module = __import__("robots."+name)
        self.robot = getattr(getattr(module, name), name.capitalize()+"Robot")()
        
        Robot.copy_from(self.robot)
        
        # On crase les attributs du robot par ceux passs ici en argument, utiles pour le testing
        for argument in kargs:
            setattr(self.robot, argument, kargs[argument])
            
                    
        self.can_sock = socket.socket()
        self.ui_sock  = socket.socket()
        self.inter  = socket.socket()
        
        self.logger.debug("Trying to connect to the CAN")
        self.can_sock.connect((self.robot.can_ip, self.robot.can_port))
        self.logger.debug("Trying to connect to the UI")
        self.ui_sock.connect((self.robot.ui_ip, self.robot.ui_port))
        self.logger.debug("Trying to connect to the INTERCOMM")
        self.inter.connect((self.robot.inter_ip, self.robot.inter_port))
        
        self.can = Can(self.can_sock)
        self.ui  = UI(self.ui_sock)
        self.inter = InterCom(self.inter)
        self.dispatcher = Dispatcher(self.robot, self.can, self.ui)
        
        self.can.dispatcher = self.dispatcher
        self.ui.dispatcher  = self.dispatcher
        self.inter.dispatcher  = self.dispatcher
        
        self.dispatcher.start() # Mieux si demarre avant can et ui
        self.can.start()
        self.ui.start()
        self.inter.start()

        self.logger.info("IA initialized")
        
        self.ui.join()
        
        self.logger.info("IA stopped")
开发者ID:7Robot,项目名称:cerveau,代码行数:54,代码来源:ia.py

示例6: main

# 需要导入模块: from dispatcher import Dispatcher [as 别名]
# 或者: from dispatcher.Dispatcher import start [as 别名]
def main():
    tasksq = multiprocessing.Queue()
    mgr = multiprocessing.Manager()
    e = mgr.Event()


    scheduler = Scheduler(e, tasksq)               # Reads the probs to be executed and queues in tasksq
    dispatcher = Dispatcher(tasksq)
    o = Oscillator(e, 1)                                    # TODO: this should be a configuration
    o.start()
    scheduler.start()
    dispatcher.start()
    o.join()
    scheduler.join()
开发者ID:karthikrev,项目名称:ThePyMonitor,代码行数:16,代码来源:pymonitor.py

示例7: __init__

# 需要导入模块: from dispatcher import Dispatcher [as 别名]
# 或者: from dispatcher.Dispatcher import start [as 别名]
class IA:

    def __init__(self, name, **kargs):

        self.logger = getLogger("ia")

        module = __import__("robots."+name) # import robots.<name>
        self.robot = getattr(getattr(module, name), name.capitalize()+"Robot")() # create <Name>Robot
        self.comm = Comm(self.robot)
        self.dispatcher = Dispatcher(self.robot, self.comm)
        self.dispatcher.start()
        self.logger.info("IA started !")
        
        from events.internal import InternalEvent
        event = InternalEvent("start")
        self.dispatcher.add_event(event)
开发者ID:7Robot-Soft,项目名称:ia,代码行数:18,代码来源:ia.py

示例8: StartDispatcher

# 需要导入模块: from dispatcher import Dispatcher [as 别名]
# 或者: from dispatcher.Dispatcher import start [as 别名]
def StartDispatcher():

    #with daemon.DaemonContext():
    #    try:
    if True:
        if True:
            dispatcher = Dispatcher(
                address='localhost',
                exchange='barkingowl',
                self_dispatch=False,
                DEBUG=True
            )

            url = {
                #'target_url': "http://timduffy.me/",
                'target_url': "http://henrietta.org/",
                'doc_types': [
                    #'application/pdf',
                    '*',
                ],
                #'title': "TimDuffy.Me",
                'title': 'Town of Henrietta, NY',
                #'description': "Tim Duffy's Personal Website",
                'description': "Town of Henrietta, NY Website.",
                #'max_link_level': 1,
                'max_link_level': 1,
                'creation_datetime': str(datetime.datetime.now()),
                'allowed_domains': [
                ],
                'sleep_time': 0, # 1 secon
            }

            urls = []
            urls.append(url)

            print "Seting URLs ..."
            dispatcher.set_urls(urls)
            print "Done."

            # note: blocking
            print "Starting dispatcher ..."
            dispatcher.start()
            print "Done."
开发者ID:thequbit,项目名称:BarkingOwl,代码行数:45,代码来源:barkingowl_dispatcher.py

示例9: dispatch

# 需要导入模块: from dispatcher import Dispatcher [as 别名]
# 或者: from dispatcher.Dispatcher import start [as 别名]
def dispatch(resultfiles):
    """
       Create dispatch semaphore and threads.
       Join threads and returns dispatch status.
    """
    threads = []
    semaphore = threading.BoundedSemaphore(value=Configuration.semaphore)

    for result in resultfiles:
        expectfile = os.path.join(Configuration.expecteddir, result)
        resultfile = os.path.join(Configuration.resultdir, result)

        t = Dispatcher(result, expectfile, resultfile, result, semaphore)
        t.start()
        threads.append(t)
                
    for t in threads:
        t.join()


    return(Dispatcher.get_pass(), Dispatcher.get_total())
开发者ID:J33ran,项目名称:Regression,代码行数:23,代码来源:regression.py

示例10: EmonHub

# 需要导入模块: from dispatcher import Dispatcher [as 别名]
# 或者: from dispatcher.Dispatcher import start [as 别名]
def EmonHub():
    
    # Load settings
    settings = ConfigObj("emonhub.conf", file_error=True)
    
    # Create queue for node packets
    queue = Queue.Queue(0)

    # Create and start serial listener
    a = Listener(queue,settings)
    a.start()
    
    # Create and start http dispatcher
    b = Dispatcher(queue,settings)
    b.start()

    while 1:
        try:
            time.sleep(0.1)
        except KeyboardInterrupt:
            print "Stopping threads"
            a.stop = True
            b.stop = True
            break
开发者ID:BuloZB,项目名称:development,代码行数:26,代码来源:03.py


注:本文中的dispatcher.Dispatcher.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。