What's the life-time of a thread-local value in Python?

Posted by Carlos Valiente on Stack Overflow See other posts from Stack Overflow or by Carlos Valiente
Published on 2009-09-25T16:16:08Z Indexed on 2010/05/21 1:00 UTC
Read the original article Hit count: 227

Filed under:
|
import threading

mydata = threading.local()

def run():
    # When will the garbage collector be able to destroy the object created
    # here? After the thread exits from ``run()``? After ``join()`` is called?
    # Or will it survive the thread in which it was created, and live until
    # ``mydata`` is garbage-collected?
    mydata.foo = object()

t = threading.Thread(target=run)
t.start()
t.join()

© Stack Overflow or respective owner

Related posts about python

Related posts about threads