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


Python local.local方法代码示例

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


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

示例1: load

# 需要导入模块: from gevent import local [as 别名]
# 或者: from gevent.local import local [as 别名]
def load(target, **namespace):
    """ Import a module or fetch an object from a module.

        * ``package.module`` returns `module` as a module object.
        * ``pack.mod:name`` returns the module variable `name` from `pack.mod`.
        * ``pack.mod:func()`` calls `pack.mod.func()` and returns the result.

        The last form accepts not only function calls, but any type of
        expression. Keyword arguments passed to this function are available as
        local variables. Example: ``import_string('re:compile(x)', x='[a-z]')``
    """
    module, target = target.split(":", 1) if ':' in target else (target, None)
    if module not in sys.modules: __import__(module)
    if not target: return sys.modules[module]
    if target.isalnum(): return getattr(sys.modules[module], target)
    package_name = module.split('.')[0]
    namespace[package_name] = sys.modules[package_name]
    return eval('%s.%s' % (module, target), namespace) 
开发者ID:Autodesk,项目名称:arnold-usd,代码行数:20,代码来源:__init__.py

示例2: _local_property

# 需要导入模块: from gevent import local [as 别名]
# 或者: from gevent.local import local [as 别名]
def _local_property():
    ls = threading.local()

    def fget(_):
        try:
            return ls.var
        except AttributeError:
            raise RuntimeError("Request context not initialized.")

    def fset(_, value):
        ls.var = value

    def fdel(_):
        del ls.var

    return property(fget, fset, fdel, 'Thread-local property') 
开发者ID:brycesub,项目名称:silvia-pi,代码行数:18,代码来源:bottle.py

示例3: load

# 需要导入模块: from gevent import local [as 别名]
# 或者: from gevent.local import local [as 别名]
def load(target, **namespace):
    """ Import a module or fetch an object from a module.
        * ``package.module`` returns `module` as a module object.
        * ``pack.mod:name`` returns the module variable `name` from `pack.mod`.
        * ``pack.mod:func()`` calls `pack.mod.func()` and returns the result.
        The last form accepts not only function calls, but any type of
        expression. Keyword arguments passed to this function are available as
        local variables. Example: ``import_string('re:compile(x)', x='[a-z]')``
    """
    module, target = target.split(":", 1) if ':' in target else (target, None)
    if module not in sys.modules: __import__(module)
    if not target: return sys.modules[module]
    if target.isalnum(): return getattr(sys.modules[module], target)
    package_name = module.split('.')[0]
    namespace[package_name] = sys.modules[package_name]
    return eval('%s.%s' % (module, target), namespace) 
开发者ID:imiyoo2010,项目名称:teye_scanner_for_book,代码行数:18,代码来源:bottle.py

示例4: __make_threadlocal

# 需要导入模块: from gevent import local [as 别名]
# 或者: from gevent.local import local [as 别名]
def __make_threadlocal(self):
        if self.__use_greenlets:
            return gevent_local()
        else:
            return threading.local() 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:mongo_replica_set_client.py

示例5: local_property

# 需要导入模块: from gevent import local [as 别名]
# 或者: from gevent.local import local [as 别名]
def local_property(name=None):
    if name: depr('local_property() is deprecated and will be removed.') #0.12
    ls = threading.local()
    def fget(self):
        try: return ls.var
        except AttributeError:
            raise RuntimeError("Request context not initialized.")
    def fset(self, value): ls.var = value
    def fdel(self): del ls.var
    return property(fget, fset, fdel, 'Thread-local property') 
开发者ID:Autodesk,项目名称:arnold-usd,代码行数:12,代码来源:__init__.py

示例6: run

# 需要导入模块: from gevent import local [as 别名]
# 或者: from gevent.local import local [as 别名]
def run(self, handler):
        from gevent import wsgi, pywsgi, local
        if not isinstance(threading.local(), local.local):
            msg = "Bottle requires gevent.monkey.patch_all() (before import)"
            raise RuntimeError(msg)
        if not self.options.pop('fast', None): wsgi = pywsgi
        self.options['log'] = None if self.quiet else 'default'
        address = (self.host, self.port)
        server = wsgi.WSGIServer(address, handler, **self.options)
        if 'BOTTLE_CHILD' in os.environ:
            import signal
            signal.signal(signal.SIGINT, lambda s, f: server.stop())
        server.serve_forever() 
开发者ID:Autodesk,项目名称:arnold-usd,代码行数:15,代码来源:__init__.py

示例7: global_config

# 需要导入模块: from gevent import local [as 别名]
# 或者: from gevent.local import local [as 别名]
def global_config(cls, key, *args):
        ''' This reads or sets the global settings stored in class.settings. '''
        if args:
            cls.settings = cls.settings.copy() # Make settings local to class
            cls.settings[key] = args[0]
        else:
            return cls.settings[key] 
开发者ID:Autodesk,项目名称:arnold-usd,代码行数:9,代码来源:__init__.py

示例8: render

# 需要导入模块: from gevent import local [as 别名]
# 或者: from gevent.local import local [as 别名]
def render(self, *args, **kwargs):
        """ Render the template with the specified local variables and return
        a single byte or unicode string. If it is a byte string, the encoding
        must match self.encoding. This method must be thread-safe!
        Local variables may be provided in dictionaries (args)
        or directly, as keywords (kwargs).
        """
        raise NotImplementedError 
开发者ID:Autodesk,项目名称:arnold-usd,代码行数:10,代码来源:__init__.py

示例9: __repr__

# 需要导入模块: from gevent import local [as 别名]
# 或者: from gevent.local import local [as 别名]
def __repr__(self):
        out = ''
        for name, value in self.headerlist:
            out += '%s: %s\n' % (name.title(), value.strip())
        return out

#: Thread-local storage for :class:`LocalRequest` and :class:`LocalResponse`
#: attributes. 
开发者ID:exiahuang,项目名称:SalesforceXyTools,代码行数:10,代码来源:bottle.py

示例10: local_property

# 需要导入模块: from gevent import local [as 别名]
# 或者: from gevent.local import local [as 别名]
def local_property(name):
    def fget(self):
        try:
            return getattr(_lctx, name)
        except AttributeError:
            raise RuntimeError("Request context not initialized.")
    def fset(self, value): setattr(_lctx, name, value)
    def fdel(self): delattr(_lctx, name)
    return property(fget, fset, fdel,
        'Thread-local property stored in :data:`_lctx.%s`' % name) 
开发者ID:exiahuang,项目名称:SalesforceXyTools,代码行数:12,代码来源:bottle.py

示例11: run

# 需要导入模块: from gevent import local [as 别名]
# 或者: from gevent.local import local [as 别名]
def run(self, handler):
        from gevent import wsgi, pywsgi, local
        if not isinstance(_lctx, local.local):
            msg = "Bottle requires gevent.monkey.patch_all() (before import)"
            raise RuntimeError(msg)
        if not self.options.get('fast'): wsgi = pywsgi
        log = None if self.quiet else 'default'
        wsgi.WSGIServer((self.host, self.port), handler, log=log).serve_forever() 
开发者ID:exiahuang,项目名称:SalesforceXyTools,代码行数:10,代码来源:bottle.py

示例12: prepare

# 需要导入模块: from gevent import local [as 别名]
# 或者: from gevent.local import local [as 别名]
def prepare(self, **options):
        from Cheetah.Template import Template
        self.context = threading.local()
        self.context.vars = {}
        options['searchList'] = [self.context.vars]
        if self.source:
            self.tpl = Template(source=self.source, **options)
        else:
            self.tpl = Template(file=self.filename, **options) 
开发者ID:exiahuang,项目名称:SalesforceXyTools,代码行数:11,代码来源:bottle.py

示例13: render

# 需要导入模块: from gevent import local [as 别名]
# 或者: from gevent.local import local [as 别名]
def render(self, *args, **kwargs):
        """ Render the template using keyword arguments as local variables. """
        for dictarg in args: kwargs.update(dictarg)
        stdout = []
        self.execute(stdout, kwargs)
        return ''.join(stdout) 
开发者ID:exiahuang,项目名称:SalesforceXyTools,代码行数:8,代码来源:bottle.py

示例14: run

# 需要导入模块: from gevent import local [as 别名]
# 或者: from gevent.local import local [as 别名]
def run(self, handler):
        from gevent import wsgi as wsgi_fast, pywsgi, monkey, local
        if self.options.get('monkey', True):
            if not threading.local is local.local: monkey.patch_all()
        wsgi = wsgi_fast if self.options.get('fast') else pywsgi
        wsgi.WSGIServer((self.host, self.port), handler).serve_forever() 
开发者ID:zhangzhengde0225,项目名称:VaspCZ,代码行数:8,代码来源:bottle.py

示例15: render

# 需要导入模块: from gevent import local [as 别名]
# 或者: from gevent.local import local [as 别名]
def render(self, *args, **kwargs):
        """ Render the template with the specified local variables and return
        a single byte or unicode string. If it is a byte string, the encoding
        must match self.encoding. This method must be thread-safe!
        Local variables may be provided in dictionaries (*args)
        or directly, as keywords (**kwargs).
        """
        raise NotImplementedError 
开发者ID:zhangzhengde0225,项目名称:VaspCZ,代码行数:10,代码来源:bottle.py


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