[docs] [issue24020] threading.local() must be run at module level (doc improvement)

eryksun report at bugs.python.org
Tue Apr 21 16:00:21 CEST 2015


eryksun added the comment:

Could you clarify what the problem is? I have no apparent problem using threading.local in a function scope:

    import threading

    def f():
        tlocal = threading.local()
        tlocal.x = 0
        def g():
            tlocal.x = 1
            print('tlocal.x in g:', tlocal.x)
        t = threading.Thread(target=g)
        t.start()
        t.join()
        print('tlocal.x in f:', tlocal.x)

    >>> f()
    tlocal.x in g: 1
    tlocal.x in f: 0

----------
nosy: +eryksun

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24020>
_______________________________________


More information about the docs mailing list