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