Python gevent 模块,local() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用gevent.local()

项目:core-python    作者:yidao620c    | 项目源码 | 文件源码
def test_local(self):
        """
        ??????
        ?????gevent?web???HTTP?????????????????gevent?
        """
        stash = local()
        def f1():
            stash.x = 1
            print(stash.x)

        def f2():
            stash.y = 2
            print(stash.y)

            try:
                stash.x
            except AttributeError:
                print("x is not local to f2")

        g1 = gevent.spawn(f1)
        g2 = gevent.spawn(f2)
        gevent.joinall([g1, g2])
项目:Python_Study    作者:thsheep    | 项目源码 | 文件源码
def f2():
    stash.y = 2
    print(stash.y)

    try:
        stash.x
    except AttributeError:
        print('x is not local to f2')

# second
项目:notebook    作者:archever    | 项目源码 | 文件源码
def f2():
    stash.y = 2
    print(stash.y)

    try:
        stash.x
    except AttributeError:
        print("x is not local to f2")