Esempio n. 1
0
def context_dict():
    """ """
    # 全局上下文,常量、静态上下文
    contexts = dict(__global_context__)
    # 动态上下文
    contexts.update({
        k.name: v[1]
        for k, v in _copy_context().items()
        if isinstance(v, list) and len(v) == 2 and isinstance(v[0], Token)
    })
    return contexts
Esempio n. 2
0
def copy_context_to_dict(inherit_scope: bool = False):
    """ """
    contexts = {}
    if inherit_scope:
        contexts.update(__scope__.get({}))
    # 全局上下文,常量、静态上下文
    contexts.update(dict(__global_context__))
    # 动态上下文
    contexts.update({
        k.name: v[1]
        for k, v in _copy_context().items()
        if isinstance(v, list) and len(v) == 2 and isinstance(v[0], Token)
    })

    return contexts
Esempio n. 3
0
 def __init__(self, fn, driver):
     greenlet.greenlet.__init__(self, fn, driver)
     self.driver = driver
     if _copy_context is not None:
         self.gr_context = _copy_context()
 def __init__(self, fn: Callable[..., Any], driver: greenlet):
     greenlet.__init__(self, fn, driver)
     self.driver = driver
     if _copy_context is not None:
         self.gr_context = _copy_context()