[pypy-commit] pypy default: Complain if we don't give "--thread" when translating an RPython program

arigo noreply at buildbot.pypy.org
Tue Oct 13 10:03:37 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r80153:137f20845896
Date: 2015-10-13 09:20 +0200
http://bitbucket.org/pypy/pypy/changeset/137f20845896/

Log:	Complain if we don't give "--thread" when translating an RPython
	program that uses start_new_thread().

diff --git a/rpython/rlib/rthread.py b/rpython/rlib/rthread.py
--- a/rpython/rlib/rthread.py
+++ b/rpython/rlib/rthread.py
@@ -79,6 +79,7 @@
 
 @specialize.arg(0)
 def ll_start_new_thread(func):
+    _check_thread_enabled()
     ident = c_thread_start(func)
     if ident == -1:
         raise error("can't start new thread")
@@ -170,6 +171,18 @@
     def _cleanup_(self):
         raise Exception("seeing a prebuilt rpython.rlib.rthread.Lock instance")
 
+def _check_thread_enabled():
+    pass
+class Entry(ExtRegistryEntry):
+    _about_ = _check_thread_enabled
+    def compute_result_annotation(self):
+        translator = self.bookkeeper.annotator.translator
+        if not translator.config.translation.thread:
+            raise Exception(
+                "this RPython program uses threads: translate with '--thread'")
+    def specialize_call(self, hop):
+        hop.exception_cannot_occur()
+
 # ____________________________________________________________
 #
 # Stack size


More information about the pypy-commit mailing list