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 { ...@@ -118,6 +118,8 @@ typedef struct _ts {
PyObject *curexc_traceback; PyObject *curexc_traceback;
PyObject *dict; /* Stores per-thread state */ PyObject *dict; /* Stores per-thread state */
// Pyston note: additions in here need to be mirrored in ThreadStateInternal::accept
} PyThreadState; } PyThreadState;
......
import gc
import threading import threading
a = threading.local() a = threading.local()
...@@ -7,9 +8,14 @@ def f(): ...@@ -7,9 +8,14 @@ def f():
a.x = "goodbye world" a.x = "goodbye world"
print a.x print a.x
thread = threading.Thread(target=f) def test():
thread.start() thread = threading.Thread(target=f)
thread.join() thread.start()
thread.join()
print a.x print a.x
print getattr(a, "doesnt_exist", 5) 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