Example #1
0
def setup_init_functions(eci, translating):
    if translating:
        prefix = "PyPy"
    else:
        prefix = "cpyexttest"
    # jump through hoops to avoid releasing the GIL during initialization
    # of the cpyext module.  The C functions are called with no wrapper,
    # but must not do anything like calling back PyType_Ready().  We
    # use them just to get a pointer to the PyTypeObjects defined in C.
    get_buffer_type = rffi.llexternal(
        "_%s_get_buffer_type" % prefix, [], PyTypeObjectPtr, compilation_info=eci, _nowrapper=True
    )
    get_cobject_type = rffi.llexternal(
        "_%s_get_cobject_type" % prefix, [], PyTypeObjectPtr, compilation_info=eci, _nowrapper=True
    )
    get_capsule_type = rffi.llexternal(
        "_%s_get_capsule_type" % prefix, [], PyTypeObjectPtr, compilation_info=eci, _nowrapper=True
    )

    def init_types(space):
        from pypy.module.cpyext.typeobject import py_type_ready

        py_type_ready(space, get_buffer_type())
        py_type_ready(space, get_cobject_type())
        py_type_ready(space, get_capsule_type())

    INIT_FUNCTIONS.append(init_types)
    from pypy.module.posix.interp_posix import add_fork_hook

    reinit_tls = rffi.llexternal("%sThread_ReInitTLS" % prefix, [], lltype.Void, compilation_info=eci)
    add_fork_hook("child", reinit_tls)
Example #2
0
File: api.py Project: juokaz/pypy
def setup_init_functions(eci, translating):
    if translating:
        prefix = 'PyPy'
    else:
        prefix = 'cpyexttest'
    # jump through hoops to avoid releasing the GIL during initialization
    # of the cpyext module.  The C functions are called with no wrapper,
    # but must not do anything like calling back PyType_Ready().  We
    # use them just to get a pointer to the PyTypeObjects defined in C.
    get_buffer_type = rffi.llexternal('_%s_get_buffer_type' % prefix,
                                      [], PyTypeObjectPtr,
                                      compilation_info=eci, _nowrapper=True)
    get_cobject_type = rffi.llexternal('_%s_get_cobject_type' % prefix,
                                       [], PyTypeObjectPtr,
                                       compilation_info=eci, _nowrapper=True)
    get_capsule_type = rffi.llexternal('_%s_get_capsule_type' % prefix,
                                       [], PyTypeObjectPtr,
                                       compilation_info=eci, _nowrapper=True)
    def init_types(space):
        from pypy.module.cpyext.typeobject import py_type_ready
        py_type_ready(space, get_buffer_type())
        py_type_ready(space, get_cobject_type())
        py_type_ready(space, get_capsule_type())
    INIT_FUNCTIONS.append(init_types)
    from pypy.module.posix.interp_posix import add_fork_hook
    reinit_tls = rffi.llexternal('%sThread_ReInitTLS' % prefix, [], lltype.Void,
                                 compilation_info=eci)
    add_fork_hook('child', reinit_tls)
Example #3
0
    def __init__(self, space, *args):
        "NOT_RPYTHON: patches space.threadlocals to use real threadlocals"
        from pypy.module.thread import gil
        MixedModule.__init__(self, space, *args)
        prev = space.threadlocals.getvalue()
        space.threadlocals = gil.GILThreadLocals()
        space.threadlocals.initialize(space)
        space.threadlocals.setvalue(prev)

        from pypy.module.posix.interp_posix import add_fork_hook
        from pypy.module.thread.os_thread import reinit_threads
        add_fork_hook('child', reinit_threads)
Example #4
0
    def __init__(self, space, *args):
        "NOT_RPYTHON: patches space.threadlocals to use real threadlocals"
        from pypy.module.thread import gil
        MixedModule.__init__(self, space, *args)
        prev = space.threadlocals.getvalue()
        space.threadlocals = gil.GILThreadLocals()
        space.threadlocals.initialize(space)
        space.threadlocals.setvalue(prev)

        from pypy.module.posix.interp_posix import add_fork_hook
        from pypy.module.thread.os_thread import reinit_threads
        add_fork_hook('child', reinit_threads)
Example #5
0
def setup_init_functions(eci):
    init_buffer = rffi.llexternal('init_bufferobject', [], lltype.Void, compilation_info=eci)
    init_pycobject = rffi.llexternal('init_pycobject', [], lltype.Void, compilation_info=eci)
    init_capsule = rffi.llexternal('init_capsule', [], lltype.Void, compilation_info=eci)
    INIT_FUNCTIONS.extend([
        lambda space: init_buffer(),
        lambda space: init_pycobject(),
        lambda space: init_capsule(),
    ])
    from pypy.module.posix.interp_posix import add_fork_hook
    reinit_tls = rffi.llexternal('PyThread_ReInitTLS', [], lltype.Void,
                                 compilation_info=eci)    
    add_fork_hook('child', reinit_tls)
Example #6
0
def setup_init_functions(eci):
    init_buffer = rffi.llexternal('init_bufferobject', [],
                                  lltype.Void,
                                  compilation_info=eci)
    init_pycobject = rffi.llexternal('init_pycobject', [],
                                     lltype.Void,
                                     compilation_info=eci)
    init_capsule = rffi.llexternal('init_capsule', [],
                                   lltype.Void,
                                   compilation_info=eci)
    INIT_FUNCTIONS.extend([
        lambda space: init_buffer(),
        lambda space: init_pycobject(),
        lambda space: init_capsule(),
    ])
    from pypy.module.posix.interp_posix import add_fork_hook
    reinit_tls = rffi.llexternal('PyThread_ReInitTLS', [],
                                 lltype.Void,
                                 compilation_info=eci)
    add_fork_hook('child', reinit_tls)
Example #7
0
 def __init__(self, space, *args):
     "NOT_RPYTHON"
     MixedModule.__init__(self, space, *args)
     from pypy.module.posix.interp_posix import add_fork_hook
     from pypy.module.imp import interp_imp
     add_fork_hook('before', interp_imp.acquire_lock)
     add_fork_hook('parent', interp_imp.release_lock)
     add_fork_hook('child', interp_imp.reinit_lock)
Example #8
0
 def __init__(self, space, *args):
     "NOT_RPYTHON"
     MixedModule.__init__(self, space, *args)
     from pypy.module.posix.interp_posix import add_fork_hook
     from pypy.module.imp import interp_imp
     add_fork_hook('before', interp_imp.acquire_lock)
     add_fork_hook('parent', interp_imp.release_lock)
     add_fork_hook('child', interp_imp.reinit_lock)