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


Python multiprocessing.queues方法代码示例

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


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

示例1: add_evaluator_workers

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import queues [as 别名]
def add_evaluator_workers(self):
        """Add evaluator workers

        Evaluator workers receive all graph updates, hence are updated.
        Each evaluator worker holds an enabled scenario-evaluator and process
        every change.
        Each worker's scenario-evaluator runs different template scenarios.
        Interface to these workers is:
        submit_graph_update(..)
        submit_start_evaluations(..)
        submit_evaluators_reload_templates(..)
        """
        if self._evaluator_queues:
            raise VitrageError('add_evaluator_workers called more than once')
        workers = CONF.evaluator.workers
        queues = [multiprocessing.JoinableQueue() for i in range(workers)]
        self.add(EvaluatorWorker,
                 args=(queues, workers),
                 workers=workers)
        self._evaluator_queues = queues
        self._all_queues.extend(queues) 
开发者ID:openstack,项目名称:vitrage,代码行数:23,代码来源:workers.py

示例2: lenient

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import queues [as 别名]
def lenient(self, lenient):
        if lenient not in (False, True):
            raise ValueError("Invalid lenient value: {}".format(lenient))
        self.__lenient = lenient

    # @property
    # def submission_queue(self):
    #     return self.__submission_queue
    #
    # def __set_submission_queue(self, submission):
    #     if isinstance(submission, multiprocessing.queues.SimpleQueue):
    #         if sys.version_info.minor < 6:
    #             raise TypeError("Invalid queue object for Python 3.5 and earlier!")
    #         submission.put_nowait = submission.put
    #     elif not isinstance(submission, (multiprocessing.queues.Queue,
    #                                    queue.Queue)):
    #         raise TypeError("Invalid queue object: {}".format(type(submission)))
    #     self.__submission_queue = submission
    # 
开发者ID:EI-CoreBioinformatics,项目名称:mikado,代码行数:21,代码来源:checking.py

示例3: add_api_workers

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import queues [as 别名]
def add_api_workers(self):
        """Add Api workers

        Api workers receive all graph updates, hence are updated.
        Each template worker holds a disabled scenario-evaluator that does
        not process changes.
        These also hold a rpc server and process the incoming Api calls
        """
        if self._api_queues:
            raise VitrageError('add_api_workers called more than once')
        workers = CONF.api.workers
        queues = [multiprocessing.Queue() for i in range(workers)]
        self.add(ApiWorker, args=(queues,), workers=workers)
        self._api_queues = queues
        self._all_queues.extend(queues) 
开发者ID:openstack,项目名称:vitrage,代码行数:17,代码来源:workers.py

示例4: _submit_and_wait

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import queues [as 别名]
def _submit_and_wait(queues, payload):
        for q in queues:
            q.put(payload)
        for q in queues:
            if isinstance(q, multiprocessing.queues.JoinableQueue):
                q.join() 
开发者ID:openstack,项目名称:vitrage,代码行数:8,代码来源:workers.py

示例5: _read_queue

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import queues [as 别名]
def _read_queue(self):
        LOG.debug("%s - reading queue %s",
                  self.__class__.__name__, self.worker_id)
        while True:
            try:
                next_task = self._task_queue.get()
                self.do_task(next_task)
            except Exception:
                LOG.exception("Graph may not be in sync.")
            if isinstance(self._task_queue,
                          multiprocessing.queues.JoinableQueue):
                self._task_queue.task_done() 
开发者ID:openstack,项目名称:vitrage,代码行数:14,代码来源:workers.py

示例6: pool_worker_main

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import queues [as 别名]
def pool_worker_main(item: WorkItemInput, output: multiprocessing.queues.Queue) -> None:
    try:
        # TODO figure out a more reliable way to suppress this. Redirect output?
        # Ignore ctrl-c in workers to reduce noisy tracebacks (the parent will kill us):
        signal.signal(signal.SIGINT, signal.SIG_IGN)

        if hasattr(os, 'nice'): # analysis should run at a low priority
            os.nice(10)
        set_debug(False)
        filename, options, deadline = item
        stats: Counter[str] = Counter()
        options.stats = stats
        _, module_name = extract_module_from_file(filename)
        try:
            module = load_by_qualname(module_name)
        except NotFound:
            return
        except ErrorDuringImport as e:
            output.put((filename, stats, [import_error_msg(e)]))
            debug(f'Not analyzing "{filename}" because import failed: {e}')
            return
        messages = analyze_any(module, options)
        output.put((filename, stats, messages))
    except BaseException as e:
        raise CrosshairInternal(
            'Worker failed while analyzing ' + filename) from e 
开发者ID:pschanely,项目名称:CrossHair,代码行数:28,代码来源:main.py

示例7: __set_logging_queue

# 需要导入模块: import multiprocessing [as 别名]
# 或者: from multiprocessing import queues [as 别名]
def __set_logging_queue(self, logging_queue):
        if isinstance(logging_queue, multiprocessing.queues.SimpleQueue):
            if sys.version_info.minor < 6:
                raise TypeError("Invalid queue object for Python 3.5 and earlier!")
            logging_queue.put_nowait = logging_queue.put
        elif not isinstance(logging_queue, (multiprocessing.queues.Queue, queue.Queue)):
            raise TypeError("Invalid queue object: {}".format(type(logging_queue)))
        self.__logging_queue = logging_queue 
开发者ID:EI-CoreBioinformatics,项目名称:mikado,代码行数:10,代码来源:checking.py


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