Commit 7212a261 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Add some notes about threading.locals

Marius beat me to the punch with the fix this time :)
parent 4b51f74e
......@@ -118,6 +118,8 @@ typedef struct _ts {
PyObject *curexc_traceback;
PyObject *dict; /* Stores per-thread state */
// Pyston note: additions in here need to be mirrored in ThreadStateInternal::accept
} PyThreadState;
......
import gc
import threading
a = threading.local()
......@@ -7,9 +8,14 @@ def f():
a.x = "goodbye world"
print a.x
thread = threading.Thread(target=f)
thread.start()
thread.join()
def test():
thread = threading.Thread(target=f)
thread.start()
thread.join()
print a.x
print getattr(a, "doesnt_exist", 5)
print a.x
print getattr(a, "doesnt_exist", 5)
for i in xrange(10):
test()
gc.collect()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment