Author: Armin Rigo <[email protected]>
Branch: ec-threadlocal
Changeset: r72136:195d984c8ff1
Date: 2014-06-22 18:20 +0200
http://bitbucket.org/pypy/pypy/changeset/195d984c8ff1/
Log: Move this prebuilt instance in the class, instead of having it be a
real global.
diff --git a/pypy/module/thread/test/test_gil.py
b/pypy/module/thread/test/test_gil.py
--- a/pypy/module/thread/test/test_gil.py
+++ b/pypy/module/thread/test/test_gil.py
@@ -64,13 +64,14 @@
except Exception, e:
assert 0
thread.gc_thread_die()
+ my_gil_threadlocals = gil.GILThreadLocals()
def f():
state.data = []
state.datalen1 = 0
state.datalen2 = 0
state.datalen3 = 0
state.datalen4 = 0
- state.threadlocals = gil.GILThreadLocals()
+ state.threadlocals = my_gil_threadlocals
state.threadlocals.setup_threads(space)
subident = thread.start_new_thread(bootstrap, ())
mainident = thread.get_ident()
diff --git a/pypy/module/thread/threadlocals.py
b/pypy/module/thread/threadlocals.py
--- a/pypy/module/thread/threadlocals.py
+++ b/pypy/module/thread/threadlocals.py
@@ -6,8 +6,6 @@
ExecutionContext._signals_enabled = 0 # default value
-raw_thread_local = rthread.ThreadLocalReference(ExecutionContext)
-
class OSThreadLocals:
"""Thread-local storage for OS-level threads.
@@ -16,8 +14,10 @@
os_thread.bootstrap()."""
def __init__(self):
+ "NOT_RPYTHON"
self._valuedict = {} # {thread_ident: ExecutionContext()}
self._cleanup_()
+ self.raw_thread_local = rthread.ThreadLocalReference(ExecutionContext)
def _cleanup_(self):
self._valuedict.clear()
@@ -35,7 +35,7 @@
self._valuedict[ident] = ec
# This logic relies on hacks and _make_sure_does_not_move().
# It only works because we keep the 'ec' alive in '_valuedict' too.
- raw_thread_local.set(ec)
+ self.raw_thread_local.set(ec)
def leave_thread(self, space):
"Notification that the current thread is about to stop."
@@ -45,7 +45,7 @@
try:
thread_is_stopping(ec)
finally:
- raw_thread_local.set(None)
+ self.raw_thread_local.set(None)
ident = rthread.get_ident()
try:
del self._valuedict[ident]
@@ -53,7 +53,7 @@
pass
def get_ec(self):
- ec = raw_thread_local.get()
+ ec = self.raw_thread_local.get()
if not we_are_translated():
assert ec is self._valuedict.get(rthread.get_ident(), None)
return ec
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit