當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。