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


Python Config.is_eventlet方法代码示例

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


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

示例1: check_output

# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import is_eventlet [as 别名]
def check_output(*popenargs, **kwargs):
    global _check_output_impl
    if _check_output_impl is None:
        from cattle import Config
        if Config.is_eventlet() and 'e_check_output' in globals():
            _check_output_impl = e_check_output
        else:
            try:
                import subprocess32
                _check_output_impl = subprocess32.check_output
            except:
                if 'check_output' in dir(subprocess):
                    _check_output_impl = subprocess.check_output
                else:
                    _check_output_impl = _check_output

    try:
        return _check_output_impl(*popenargs, **kwargs)
    except subprocess.CalledProcessError as e:
        raise e
    except Exception as e:
        # eventlets seems to throw a CalledProcessError that isn't the same
        # as the subprocess package exception
        try:
            raise subprocess.CalledProcessError(e.returncode, e.cmd, e.output)
        except subprocess.CalledProcessError as e1:
            raise e1
        except:
            # This is in case CallProcessError doesn't have returncode, cmd,
            # or output
            raise e
开发者ID:timbutler,项目名称:python-agent,代码行数:33,代码来源:utils.py

示例2: check_output

# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import is_eventlet [as 别名]
def check_output(*popenargs, **kwargs):
    global _check_output_impl
    if _check_output_impl is None:
        from cattle import Config
        if Config.is_eventlet() and 'e_check_output' in globals():
            _check_output_impl = e_check_output
        else:
            try:
                import subprocess32
                _check_output_impl = subprocess32.check_output
            except:
                if 'check_output' in dir(subprocess):
                    _check_output_impl = subprocess.check_output
                else:
                    _check_output_impl = _check_output

    return _check_output_impl(*popenargs, **kwargs)
开发者ID:assimilator101,项目名称:cattle,代码行数:19,代码来源:utils.py

示例3: blocking

# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import is_eventlet [as 别名]
def blocking(method, *args, **kw):
    if Config.is_eventlet():
        return tpool.execute(method, *args, **kw)
    else:
        return method(*args, **kw)
开发者ID:keras,项目名称:python-agent,代码行数:7,代码来源:concurrency.py

示例4: run

# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import is_eventlet [as 别名]
def run(method, *args):
    if Config.is_eventlet():
        pool.spawn(method, *args).wait()
    else:
        method(*args)
开发者ID:keras,项目名称:python-agent,代码行数:7,代码来源:concurrency.py

示例5: __init__

# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import is_eventlet [as 别名]
import logging
from cattle import Config

log = logging.getLogger("concurrency")

__all__ = ["Queue", "Empty", "Full", "Worker", "run", "spawn", "blocking"]

if Config.is_eventlet():
    import eventlet

    eventlet.monkey_patch()
    from eventlet.queue import Queue, Empty, Full
    from eventlet import tpool

    pool = eventlet.GreenPool(size=Config.workers() * 2)

    class Worker:
        def __init__(self, target=None, args=None):
            self._target = target
            self._args = args

        def start(self):
            pool.spawn_n(self._target, *self._args)

    log.info("Using eventlet")

    port = Config.eventlet_backdoor()

    if port:
        from eventlet import backdoor
开发者ID:keras,项目名称:python-agent,代码行数:32,代码来源:concurrency.py

示例6: new_websocket_client

# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import is_eventlet [as 别名]
                def new_websocket_client(self):
                    if Config.is_eventlet():
                        from eventlet import hubs
                        hubs.use_hub()

                    return ProxyRequestHandler.new_websocket_client(self)
开发者ID:assimilator101,项目名称:cattle,代码行数:8,代码来源:__init__.py


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