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


Python eventlet.Timeout方法代码示例

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


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

示例1: run

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import Timeout [as 别名]
def run(self):
        acceptors = []
        for sock in self.sockets:
            gsock = GreenSocket(sock)
            gsock.setblocking(1)
            hfun = partial(self.handle, gsock)
            acceptor = eventlet.spawn(_eventlet_serve, gsock, hfun,
                                      self.worker_connections)

            acceptors.append(acceptor)
            eventlet.sleep(0.0)

        while self.alive:
            self.notify()
            eventlet.sleep(1.0)

        self.notify()
        try:
            with eventlet.Timeout(self.cfg.graceful_timeout) as t:
                [a.kill(eventlet.StopServe()) for a in acceptors]
                [a.wait() for a in acceptors]
        except eventlet.Timeout as te:
            if te != t:
                raise
            [a.kill() for a in acceptors] 
开发者ID:jpush,项目名称:jbox,代码行数:27,代码来源:geventlet.py

示例2: test_do_afxr_fails_with_timeout

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import Timeout [as 别名]
def test_do_afxr_fails_with_timeout(self, mock_cancel, mock_from_xfr,
                                        mock_xfr):
        mock_from_xfr.side_effect = eventlet.Timeout()

        masters = [
            {'host': '192.168.0.1', 'port': 53},
            {'host': '192.168.0.2', 'port': 53},
            {'host': '192.168.0.3', 'port': 53},
            {'host': '192.168.0.4', 'port': 53},
        ]

        self.assertRaises(
            exceptions.XFRFailure,
            dnsutils.do_axfr, 'example.com.', masters,
        )

        self.assertTrue(mock_xfr.called)
        self.assertTrue(mock_from_xfr.called)
        self.assertTrue(mock_cancel.called) 
开发者ID:openstack,项目名称:designate,代码行数:21,代码来源:test_dnsutils.py

示例3: poll_response

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import Timeout [as 别名]
def poll_response(self, response):
        """
        The API might return a job nr in the response in case of a async
        response: https://github.com/fog/fog/issues/575
        """
        status = response.status

        timeout = Timeout(CONF[CFG_GROUP_NAME].job_timeout)
        try:
            while status == 307:
                time.sleep(1)
                url = response.headers.get('Location')
                LOG.debug("Polling %s", url)

                polled_response = self.get(url)
                status = response.status
        except Timeout as t:
            if t == timeout:
                raise DynTimeoutError('Timeout reached when pulling job.')
        finally:
            timeout.cancel()
        return polled_response 
开发者ID:openstack,项目名称:designate,代码行数:24,代码来源:impl_dynect.py

示例4: evenlet_timeout_deco

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import Timeout [as 别名]
def evenlet_timeout_deco(timeout_t):
    def _evenlet_timeout_deco(f):
        def __evenlet_timeout_deco(*args, **kwargs):
            timeout = Timeout(timeout_t, )
            # timeout.start()  # 与gevent不一样,直接start了。
            result = None
            try:
                result = f(*args, **kwargs)
            except Timeout as t:
                logger_evenlet_timeout_deco.error(f'函数 {f} 运行超过了 {timeout_t} 秒')
                if t is not timeout:
                    nb_print(t)
                    # raise  # not my timeout
            finally:
                timeout.cancel()
                return result

        return __evenlet_timeout_deco

    return _evenlet_timeout_deco 
开发者ID:ydf0509,项目名称:distributed_framework,代码行数:22,代码来源:custom_evenlet_pool_executor.py

示例5: get_path

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import Timeout [as 别名]
def get_path(self, project_file=None):
        """Get the absolute path to a file. Used for testing the API.

        :param project_file: File whose path to return. Default: None.
        :returns: path to the specified file, or path to project root.
        """
        root = os.path.abspath(
            os.path.join(os.path.dirname(__file__), '..', '..')
            )
        if project_file:
            return os.path.join(root, project_file)
        else:
            return root


# Test worker cannot survive eventlet's Timeout exception, which effectively
# kills the whole worker, with all test cases scheduled to it. This metaclass
# makes all test cases convert Timeout exceptions into unittest friendly
# failure mode (self.fail). 
开发者ID:openstack,项目名称:cyborg,代码行数:21,代码来源:base.py

示例6: test_PUT_timeout_during_data_transfer

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import Timeout [as 别名]
def test_PUT_timeout_during_data_transfer(self):
        """The gateway times out while upload data to the server."""
        class FakeReader(object):
            def read(self, size):
                raise Timeout()

        req = Request.blank('/v1/a/c/o.jpg', method='PUT',
                            body='test body')
        req.environ['wsgi.input'] = FakeReader()
        req.headers['content-length'] = '6'
        chunks = [{"url": "http://127.0.0.1:7000/AAAA", "pos": "0", "size": 6}]
        meta = fake_prepare_meta()
        self.storage.container.content_prepare = Mock(
            return_value=(meta, chunks))
        with patch('oio.api.replication.io.http_connect',
                   new=fake_http_connect):
            resp = req.get_response(self.app)
            self.assertEqual(503, resp.status_int) 
开发者ID:open-io,项目名称:oio-swift,代码行数:20,代码来源:test_obj.py

示例7: execute_run

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import Timeout [as 别名]
def execute_run(self, exec_id, command):
        with docker_utils.docker_client() as docker:
            try:
                with eventlet.Timeout(CONF.docker.execute_timeout):
                    output = docker.exec_start(exec_id, False, False, False)
            except eventlet.Timeout:
                raise exception.Conflict(_(
                    "Timeout on executing command: %s") % command)
            inspect_res = docker.exec_inspect(exec_id)
            return output, inspect_res['ExitCode'] 
开发者ID:openstack,项目名称:zun,代码行数:12,代码来源:driver.py

示例8: timeout_ctx

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import Timeout [as 别名]
def timeout_ctx(self):
        return eventlet.Timeout(self.cfg.keepalive or None, False) 
开发者ID:jpush,项目名称:jbox,代码行数:4,代码来源:geventlet.py

示例9: Timeout

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import Timeout [as 别名]
def Timeout(self, timeout, raise_after=True):
        return eventlet.Timeout(timeout, raise_after) 
开发者ID:noisyboiler,项目名称:wampy,代码行数:4,代码来源:eventlet_.py

示例10: receive_message

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import Timeout [as 别名]
def receive_message(self, timeout):
        try:
            message = self._wait_for_message(timeout)
        except eventlet.Timeout:
            raise WampyTimeOutError(
                "no message returned (timed-out in {})".format(timeout)
            )
        return message 
开发者ID:noisyboiler,项目名称:wampy,代码行数:10,代码来源:eventlet_.py

示例11: _wait_for_message

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import Timeout [as 别名]
def _wait_for_message(self, timeout):
        q = self.message_queue

        with eventlet.Timeout(timeout):
            while q.qsize() == 0:
                eventlet.sleep()

        message = q.get()
        return message 
开发者ID:noisyboiler,项目名称:wampy,代码行数:11,代码来源:eventlet_.py

示例12: __init__

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import Timeout [as 别名]
def __init__(self):
        super(TimeoutException, self).__init__('Timeout') 
开发者ID:openstack,项目名称:dragonflow,代码行数:4,代码来源:app_testing_objects.py

示例13: wait

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import Timeout [as 别名]
def wait(self, timeout, exception):
        with eventlet.Timeout(timeout, exception):
            try:
                self.daemon.wait()
            except greenlet.GreenletExit:
                return True 
开发者ID:openstack,项目名称:dragonflow,代码行数:8,代码来源:app_testing_objects.py

示例14: tara

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import Timeout [as 别名]
def tara(ip):
	try:
		with eventlet.Timeout(3):
			address = 'http://'+ip+':8545'
			data = {"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}
			headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
			r = requests.post(address, data=json.dumps(data), headers=headers, timeout=3)
			return r.text
	except: 
	  pass 
开发者ID:tolgatasci,项目名称:geth-hack,代码行数:12,代码来源:start.py

示例15: _as_timed_sync_func

# 需要导入模块: import eventlet [as 别名]
# 或者: from eventlet import Timeout [as 别名]
def _as_timed_sync_func(self, sync_func, name, timeout):
        def _timed_sync():
            with eventlet.Timeout(
                timeout,
                exception=exception.ClusterDataModelCollectionError(cdm=name)
            ):
                sync_func()

        return _timed_sync 
开发者ID:openstack,项目名称:watcher,代码行数:11,代码来源:scheduling.py


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