Skip to content

Instantly share code, notes, and snippets.

@unbit
Created May 18, 2013 11:03
Show Gist options
  • Save unbit/5604066 to your computer and use it in GitHub Desktop.
Save unbit/5604066 to your computer and use it in GitHub Desktop.
pypy new funcs for uWSGI
diff -r 32dd588a5e23 pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py Fri May 17 16:41:25 2013 -0700
+++ b/pypy/goal/targetpypystandalone.py Sat May 18 13:03:29 2013 +0200
@@ -10,6 +10,8 @@
from rpython.config.config import ConflictConfigError
from pypy.tool.option import make_objspace
from pypy.conftest import pypydir
+from rpython.rlib import rthread
+from pypy.module.thread import os_thread
thisdir = py.path.local(__file__).dirpath()
@@ -120,6 +122,23 @@
source = rffi.charp2str(ll_source)
return _pypy_execute_source(source)
+ @entrypoint('main', [], c_name='pypy_init_threads')
+ def pypy_init_threads():
+ os_thread.setup_threads(space)
+ rffi.aroundstate.before()
+
+ @entrypoint('main', [], c_name='pypy_thread_attach')
+ def pypy_thread_attach():
+ rthread.gc_thread_prepare()
+ rthread.gc_thread_start()
+ """
+ rffi.aroundstate.after()
+ try:
+ rthread.gc_thread_start()
+ finally:
+ rffi.aroundstate.before()
+ """
+
w_globals = space.newdict()
space.setitem(w_globals, space.wrap('__builtins__'),
space.builtin_modules['__builtin__'])
@@ -137,6 +156,8 @@
return 0
return entry_point, {'pypy_execute_source': pypy_execute_source,
+ 'pypy_init_threads': pypy_init_threads,
+ 'pypy_thread_attach': pypy_thread_attach,
'pypy_setup_home': pypy_setup_home}
def call_finish(space):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment