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


Python futurist.GreenThreadPoolExecutor方法代码示例

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


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

示例1: __init__

# 需要导入模块: import futurist [as 别名]
# 或者: from futurist import GreenThreadPoolExecutor [as 别名]
def __init__(self, operation_manager, thread_count=None):
        super(ThreadPoolExecutor, self).__init__(operation_manager)

        if thread_count is None:
            thread_count = CONF.thread_count

        self._pool = futurist.GreenThreadPoolExecutor(thread_count)
        self._operation_to_run = defaultdict(int)
        self._operation_to_cancel = set()
        self._lock = RLock()

        self._check_functions = {
            self._CHECK_ITEMS['is_waiting']: lambda op_id: (
                op_id in self._operation_to_run),

            self._CHECK_ITEMS['is_canceled']: lambda op_id: (
                op_id in self._operation_to_cancel),
        } 
开发者ID:openstack,项目名称:karbor,代码行数:20,代码来源:thread_pool_executor.py

示例2: get_engine

# 需要导入模块: import futurist [as 别名]
# 或者: from futurist import GreenThreadPoolExecutor [as 别名]
def get_engine(self, flow, **kwargs):
        if flow is None:
            LOG.error("The flow is None, build it first")
            raise exception.InvalidTaskFlowObject(
                reason=_("The flow is None"))
        executor = kwargs.get('executor', None)
        engine = kwargs.get('engine', None)
        store = kwargs.get('store', None)
        if not executor:
            executor = futurist.GreenThreadPoolExecutor()
        if not engine:
            engine = 'parallel'
        flow_engine = engines.load(flow,
                                   executor=executor,
                                   engine=engine,
                                   store=store)
        return flow_engine 
开发者ID:openstack,项目名称:karbor,代码行数:19,代码来源:workflow.py

示例3: get_engine

# 需要导入模块: import futurist [as 别名]
# 或者: from futurist import GreenThreadPoolExecutor [as 别名]
def get_engine(self, flow, **kwargs):
        if flow is None:
            LOG.error("Flow is None, build it first")
            return
        executor = kwargs.get('executor', None)
        engine = kwargs.get('engine', None)
        store = kwargs.get('store', None)
        if not executor:
            executor = futurist.GreenThreadPoolExecutor()
        if not engine:
            engine = 'parallel'
        flow_engine = engines.load(flow,
                                   executor=executor,
                                   engine=engine,
                                   store=store)
        return flow_engine 
开发者ID:openstack,项目名称:karbor,代码行数:18,代码来源:fakes.py

示例4: default_executor

# 需要导入模块: import futurist [as 别名]
# 或者: from futurist import GreenThreadPoolExecutor [as 别名]
def default_executor():
    thread_count = 5
    try:
        thread_count = CONF['service:worker'].threads
    except Exception:
        pass

    # TODO(mugsie): if (when) we move away from eventlet this may have to
    # revert back to ThreadPoolExecutor - this is changing due to
    # https://bugs.launchpad.net/bugs/1782647 (eventlet + py37 issues)
    return futurist.GreenThreadPoolExecutor(thread_count) 
开发者ID:openstack,项目名称:designate,代码行数:13,代码来源:processing.py

示例5: list_floatingips

# 需要导入模块: import futurist [as 别名]
# 或者: from futurist import GreenThreadPoolExecutor [as 别名]
def list_floatingips(self, context, region=None):
        """
        Get floating ips based on the current context from Neutron
        """
        endpoints = self._endpoints(
            service_catalog=context.service_catalog,
            service_type='network',
            endpoint_type=CONF['network_api:neutron'].endpoint_type,
            config_section='network_api:neutron',
            region=region
        )

        floating_ips = []
        with futurist.GreenThreadPoolExecutor(max_workers=5) as executor:
            executors = [
                executor.submit(
                    self._get_floating_ips,
                    context,
                    endpoint,
                    region,
                    project_id=context.project_id
                ) for endpoint, region in endpoints
            ]
            for future in concurrent.futures.as_completed(executors):
                try:
                    floating_ips.extend(future.result())
                except Exception as e:
                    raise exceptions.NeutronCommunicationFailure(e)

        return floating_ips 
开发者ID:openstack,项目名称:designate,代码行数:32,代码来源:neutron.py

示例6: __init__

# 需要导入模块: import futurist [as 别名]
# 或者: from futurist import GreenThreadPoolExecutor [as 别名]
def __init__(self, applier_manager):
        self.applier_manager = applier_manager
        workers = CONF.watcher_applier.workers
        self.executor = futurist.GreenThreadPoolExecutor(max_workers=workers) 
开发者ID:openstack,项目名称:watcher,代码行数:6,代码来源:trigger.py

示例7: __init__

# 需要导入模块: import futurist [as 别名]
# 或者: from futurist import GreenThreadPoolExecutor [as 别名]
def __init__(self, messaging):
        self._messaging = messaging
        self._executor = futurist.GreenThreadPoolExecutor(
            max_workers=CONF.watcher_decision_engine.max_audit_workers)
        self._oneshot_handler = o_handler.OneShotAuditHandler()
        self._continuous_handler = c_handler.ContinuousAuditHandler().start()
        self._event_handler = e_handler.EventAuditHandler() 
开发者ID:openstack,项目名称:watcher,代码行数:9,代码来源:audit_endpoint.py

示例8: __init__

# 需要导入模块: import futurist [as 别名]
# 或者: from futurist import GreenThreadPoolExecutor [as 别名]
def __init__(self):
        self.amount_workers = CONF.watcher_decision_engine.max_general_workers
        self._threadpool = futurist.GreenThreadPoolExecutor(
            max_workers=self.amount_workers) 
开发者ID:openstack,项目名称:watcher,代码行数:6,代码来源:threading.py

示例9: __init__

# 需要导入模块: import futurist [as 别名]
# 或者: from futurist import GreenThreadPoolExecutor [as 别名]
def __init__(self, max_workers=10):
        pool = futurist.GreenThreadPoolExecutor(int(max_workers))
        super(GreenThreadPoolExecutor, self).__init__(pool) 
开发者ID:openstack,项目名称:watcher,代码行数:5,代码来源:scheduling.py

示例10: _create_executor

# 需要导入模块: import futurist [as 别名]
# 或者: from futurist import GreenThreadPoolExecutor [as 别名]
def _create_executor(self, max_workers=None):
        if max_workers is None:
            max_workers = self.DEFAULT_WORKERS
        return futurist.GreenThreadPoolExecutor(max_workers=max_workers) 
开发者ID:openstack,项目名称:taskflow,代码行数:6,代码来源:executor.py

示例11: _make_engine

# 需要导入模块: import futurist [as 别名]
# 或者: from futurist import GreenThreadPoolExecutor [as 别名]
def _make_engine(self, flow, flow_detail=None, executor=None):
        if executor is None:
            executor = futurist.GreenThreadPoolExecutor()
            self.addCleanup(executor.shutdown)
        return taskflow.engines.load(flow,
                                     flow_detail=flow_detail,
                                     backend=self.backend,
                                     engine='parallel',
                                     executor=executor) 
开发者ID:openstack,项目名称:taskflow,代码行数:11,代码来源:test_arguments_passing.py

示例12: test_green_executor_creation

# 需要导入模块: import futurist [as 别名]
# 或者: from futurist import GreenThreadPoolExecutor [as 别名]
def test_green_executor_creation(self):
        with futurist.GreenThreadPoolExecutor(1) as e:
            eng = self._create_engine(executor=e)
            self.assertIsInstance(eng._task_executor,
                                  executor.ParallelThreadTaskExecutor) 
开发者ID:openstack,项目名称:taskflow,代码行数:7,代码来源:test_creation.py

示例13: _make_engine

# 需要导入模块: import futurist [as 别名]
# 或者: from futurist import GreenThreadPoolExecutor [as 别名]
def _make_engine(self, flow, flow_detail=None, executor=None):
        if executor is None:
            executor = futurist.GreenThreadPoolExecutor()
            self.addCleanup(executor.shutdown)
        return taskflow.engines.load(flow, flow_detail=flow_detail,
                                     backend=self.backend, engine='parallel',
                                     executor=executor) 
开发者ID:openstack,项目名称:taskflow,代码行数:9,代码来源:test_suspend.py

示例14: executor

# 需要导入模块: import futurist [as 别名]
# 或者: from futurist import GreenThreadPoolExecutor [as 别名]
def executor():
    """Return the current futures executor."""
    global _EXECUTOR
    if _EXECUTOR is None:
        _EXECUTOR = futurist.GreenThreadPoolExecutor(
            max_workers=CONF.max_concurrency)
    return _EXECUTOR 
开发者ID:openstack,项目名称:ironic-inspector,代码行数:9,代码来源:utils.py

示例15: main

# 需要导入模块: import futurist [as 别名]
# 或者: from futurist import GreenThreadPoolExecutor [as 别名]
def main():
    if len(sys.argv) == 2:
        tbl = []
        with open(sys.argv[1], 'rb') as fh:
            reader = csv.reader(fh)
            for row in reader:
                tbl.append([float(r) if r else 0.0 for r in row])
    else:
        # Make some random table out of thin air...
        tbl = []
        cols = random.randint(1, 100)
        rows = random.randint(1, 100)
        for _i in compat_range(0, rows):
            row = []
            for _j in compat_range(0, cols):
                row.append(random.random())
            tbl.append(row)

    # Generate the work to be done.
    f = make_flow(tbl)

    # Now run it (using the specified executor)...
    try:
        executor = futurist.GreenThreadPoolExecutor(max_workers=5)
    except RuntimeError:
        # No eventlet currently active, use real threads instead.
        executor = futurist.ThreadPoolExecutor(max_workers=5)
    try:
        e = engines.load(f, engine='parallel', executor=executor)
        for st in e.run_iter():
            print(st)
    finally:
        executor.shutdown()

    # Find the old rows and put them into place...
    #
    # TODO(harlowja): probably easier just to sort instead of search...
    computed_tbl = []
    for i in compat_range(0, len(tbl)):
        for t in f:
            if t.index == i:
                computed_tbl.append(e.storage.get(t.name))

    # Do some basic validation (which causes the return code of this process
    # to be different if things were not as expected...)
    if len(computed_tbl) != len(tbl):
        return 1
    else:
        return 0 
开发者ID:openstack,项目名称:taskflow,代码行数:51,代码来源:parallel_table_multiply.py


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