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


Python eventlet.GreenPool方法代码示例

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


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

示例1: get_asynchronous_eventlet_pool

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import GreenPool [as 别名]
def get_asynchronous_eventlet_pool(size=1000):
    """Return eventlet pool to caller.

    Also store pools created in global list, to wait on
    it after getting signal for graceful shutdown.

    :param size: eventlet pool size
    :returns: eventlet pool
    """
    global ASYNC_EVENTLET_THREAD_POOL_LIST

    pool = eventlet.GreenPool(size=size)
    # Add pool to global ASYNC_EVENTLET_THREAD_POOL_LIST
    ASYNC_EVENTLET_THREAD_POOL_LIST.append(pool)

    return pool 
开发者ID:openstack,项目名称:searchlight,代码行数:18,代码来源:wsgi.py

示例2: __init__

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import GreenPool [as 别名]
def __init__(self):
        super(VNFMPlugin, self).__init__()
        self._pool = eventlet.GreenPool()
        self.boot_wait = cfg.CONF.tacker.boot_wait
        self.vim_client = vim_client.VimClient()
        self._vnf_manager = driver_manager.DriverManager(
            'tacker.tacker.vnfm.drivers',
            cfg.CONF.tacker.infra_driver)
        self._vnf_action = driver_manager.DriverManager(
            'tacker.tacker.policy.actions',
            cfg.CONF.tacker.policy_action)
        self._vnf_monitor = monitor.VNFMonitor(self.boot_wait)
        self._vnf_alarm_monitor = monitor.VNFAlarmMonitor()
        self._vnf_reservation_monitor = monitor.VNFReservationAlarmMonitor()
        self._vnf_app_monitor = monitor.VNFAppMonitor()
        self._init_monitoring() 
开发者ID:openstack,项目名称:tacker,代码行数:18,代码来源:plugin.py

示例3: _run_server

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import GreenPool [as 别名]
def _run_server():
    host = cfg.CONF.stream.host
    port = cfg.CONF.stream.port

    LOG.info('(PID=%s) ST2 Stream API is serving on http://%s:%s.', os.getpid(), host, port)

    max_pool_size = eventlet.wsgi.DEFAULT_MAX_SIMULTANEOUS_REQUESTS
    worker_pool = eventlet.GreenPool(max_pool_size)
    sock = eventlet.listen((host, port))

    def queue_shutdown(signal_number, stack_frame):
        eventlet.spawn_n(shutdown_server_kill_pending_requests, sock=sock,
                         worker_pool=worker_pool, wait_time=WSGI_SERVER_REQUEST_SHUTDOWN_TIME)

    # We register a custom SIGINT handler which allows us to kill long running active requests.
    # Note: Eventually we will support draining (waiting for short-running requests), but we
    # will still want to kill long running stream requests.
    register_stream_signal_handlers(handler_func=queue_shutdown)

    wsgi.server(sock, app.setup_app(), custom_pool=worker_pool)
    return 0 
开发者ID:StackStorm,项目名称:st2,代码行数:23,代码来源:api.py

示例4: test_runtestmulti

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import GreenPool [as 别名]
def test_runtestmulti(self):
        class MyConfig:
            class MyOption:
                numproc = 7

            option = MyOption()

        x = []

        def MyGreenPool(**kw):
            x.append(kw)
            # Building a Detox object will already call GreenPool(),
            # so we have to let MyGreenPool being called twice before raise
            if len(x) == 2:
                raise ValueError

        from detox import proc

        setattr(proc, "GreenPool", MyGreenPool)
        with pytest.raises(ValueError):
            d = proc.Detox(MyConfig())
            d.runtestsmulti(["env1", "env2", "env3"])  # Fake env list

        assert x[0] == {}  # When building Detox object
        assert x[1] == {"size": 7}  # When calling runtestsmulti 
开发者ID:tox-dev,项目名称:detox,代码行数:27,代码来源:test_detox.py

示例5: run_server

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import GreenPool [as 别名]
def run_server(self):
        """Run a WSGI server."""

        eventlet.wsgi.HttpProtocol.default_request_version = "HTTP/1.0"
        eventlet.hubs.use_hub('poll')
        eventlet.patcher.monkey_patch(all=False, socket=True)
        self.pool = eventlet.GreenPool(size=self.threads)
        socket_timeout = cfg.CONF.senlin_api.client_socket_timeout or None

        try:
            eventlet.wsgi.server(
                self.sock, self.application,
                custom_pool=self.pool,
                url_length_limit=URL_LENGTH_LIMIT,
                log=self._logger,
                debug=cfg.CONF.debug,
                keepalive=cfg.CONF.senlin_api.wsgi_keep_alive,
                socket_timeout=socket_timeout)
        except socket.error as err:
            if err[0] != errno.EINVAL:
                raise

        self.pool.waitall() 
开发者ID:openstack,项目名称:senlin,代码行数:25,代码来源:wsgi.py

示例6: init_pool

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import GreenPool [as 别名]
def init_pool(self, worker_count):
        return eventlet.GreenPool(worker_count) 
开发者ID:JohnStarich,项目名称:python-pool-performance,代码行数:4,代码来源:eventlet.py

示例7: create_pool

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import GreenPool [as 别名]
def create_pool(self):
        return eventlet.GreenPool(size=self.threads) 
开发者ID:openstack,项目名称:searchlight,代码行数:4,代码来源:wsgi.py

示例8: __init__

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import GreenPool [as 别名]
def __init__(self):
        super(NfvoPlugin, self).__init__()
        self._pool = eventlet.GreenPool()
        self._vim_drivers = driver_manager.DriverManager(
            'tacker.nfvo.vim.drivers',
            cfg.CONF.nfvo_vim.vim_drivers)
        self.vim_client = vim_client.VimClient() 
开发者ID:openstack,项目名称:tacker,代码行数:9,代码来源:nfvo_plugin.py

示例9: __init__

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import GreenPool [as 别名]
def __init__(self):
        self.message_type = LiveActionDB
        self._shutdown = False
        self._pool = eventlet.GreenPool(size=cfg.CONF.scheduler.pool_size)
        # If an ActionExecutionSchedulingQueueItemDB object hasn't been updated fore more than
        # this amount of milliseconds, it will be marked as "handled=False".
        # As soon as an item is picked by scheduler to be processed, it should be processed very
        # fast (< 5 seconds). If an item is still being marked as processing it likely indicates
        # that the scheduler process which was processing that item crashed or similar so we need
        # to mark it as "handling=False" so some other scheduler process can pick it up.
        self._execution_scheduling_timeout_threshold_ms = \
            cfg.CONF.scheduler.execution_scheduling_timeout_threshold_min * 60 * 1000
        self._coordinator = coordination_service.get_coordinator(start_heart=True)
        self._main_thread = None
        self._cleanup_thread = None 
开发者ID:StackStorm,项目名称:st2,代码行数:17,代码来源:handler.py

示例10: test_handler_retry_connection_error

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import GreenPool [as 别名]
def test_handler_retry_connection_error(self):
        scheduling_queue_handler = handler.ActionExecutionSchedulingQueueHandler()
        scheduling_queue_handler.process()

        # Make sure retry occurs and that _handle_execution in process is called.
        calls = [mock.call(scheduling_queue_handler._handle_execution, MOCK_QUEUE_ITEM)]
        eventlet.GreenPool.spawn.assert_has_calls(calls) 
开发者ID:StackStorm,项目名称:st2,代码行数:9,代码来源:test_scheduler_retry.py

示例11: test_handler_retries_exhausted

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import GreenPool [as 别名]
def test_handler_retries_exhausted(self):
        scheduling_queue_handler = handler.ActionExecutionSchedulingQueueHandler()
        self.assertRaises(pymongo.errors.ConnectionFailure, scheduling_queue_handler.process)
        self.assertEqual(eventlet.GreenPool.spawn.call_count, 0) 
开发者ID:StackStorm,项目名称:st2,代码行数:6,代码来源:test_scheduler_retry.py

示例12: test_handler_retry_unexpected_error

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import GreenPool [as 别名]
def test_handler_retry_unexpected_error(self):
        scheduling_queue_handler = handler.ActionExecutionSchedulingQueueHandler()
        self.assertRaises(KeyError, scheduling_queue_handler.process)
        self.assertEqual(eventlet.GreenPool.spawn.call_count, 0) 
开发者ID:StackStorm,项目名称:st2,代码行数:6,代码来源:test_scheduler_retry.py

示例13: __init__

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import GreenPool [as 别名]
def __init__(self, dispatch_pool_size=50, monitor_thread_empty_q_sleep_time=5,
                 monitor_thread_no_workers_sleep_time=1, name=None):
        self._pool_limit = dispatch_pool_size
        self._dispatcher_pool = eventlet.GreenPool(dispatch_pool_size)
        self._dispatch_monitor_thread = eventlet.greenthread.spawn(self._flush)
        self._monitor_thread_empty_q_sleep_time = monitor_thread_empty_q_sleep_time
        self._monitor_thread_no_workers_sleep_time = monitor_thread_no_workers_sleep_time
        self._name = name

        self._work_buffer = six.moves.queue.Queue()

        # Internal attributes we use to track how long the pool is busy without any free workers
        self._pool_last_free_ts = time.time() 
开发者ID:StackStorm,项目名称:st2,代码行数:15,代码来源:greenpooldispatch.py

示例14: _run_server

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import GreenPool [as 别名]
def _run_server():
    host = cfg.CONF.api.host
    port = cfg.CONF.api.port

    LOG.info('(PID=%s) ST2 API is serving on http://%s:%s.', os.getpid(), host, port)

    max_pool_size = eventlet.wsgi.DEFAULT_MAX_SIMULTANEOUS_REQUESTS
    worker_pool = eventlet.GreenPool(max_pool_size)
    sock = eventlet.listen((host, port))

    wsgi.server(sock, app.setup_app(), custom_pool=worker_pool, log=LOG, log_output=False)
    return 0 
开发者ID:StackStorm,项目名称:st2,代码行数:14,代码来源:api.py

示例15: runtestsmulti

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import GreenPool [as 别名]
def runtestsmulti(self, envlist):
        pool = GreenPool(size=self._toxconfig.option.numproc)
        threads = []
        for env in envlist:
            threads.append(pool.spawn(self.runtests, env))

        for t in threads:
            # re-raises any exceptions of the worker thread
            t.wait()
        if not self.toxsession.config.option.sdistonly:
            retcode = self._toxsession._summary()
            return retcode 
开发者ID:tox-dev,项目名称:detox,代码行数:14,代码来源:proc.py


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