[pypy-commit] pypy portable-threadlocal: rthread.get_ident() non-translated

arigo noreply at buildbot.pypy.org
Sat Nov 22 19:27:48 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: portable-threadlocal
Changeset: r74638:b604e908b50c
Date: 2014-11-22 19:23 +0100
http://bitbucket.org/pypy/pypy/changeset/b604e908b50c/

Log:	rthread.get_ident() non-translated

diff --git a/rpython/rlib/rthread.py b/rpython/rlib/rthread.py
--- a/rpython/rlib/rthread.py
+++ b/rpython/rlib/rthread.py
@@ -84,7 +84,11 @@
 # wrappers...
 
 def get_ident():
-    return tlfield_thread_ident.getraw()
+    if we_are_translated():
+        return tlfield_thread_ident.getraw()
+    else:
+        import thread
+        return thread.get_ident()
 
 @specialize.arg(0)
 def start_new_thread(x, y):
diff --git a/rpython/rlib/test/test_rthread.py b/rpython/rlib/test/test_rthread.py
--- a/rpython/rlib/test/test_rthread.py
+++ b/rpython/rlib/test/test_rthread.py
@@ -47,6 +47,10 @@
     time.sleep(0.5)
     assert results == [True] * 15
 
+def test_get_ident():
+    import thread
+    assert get_ident() == thread.get_ident()
+
 
 class AbstractThreadTests(AbstractGCTestClass):
     use_threads = True


More information about the pypy-commit mailing list