Пример #1
0
 def bootstrap():
     rthread.gc_thread_start()
     _sleep(1)
     revdb.stop_point()
     _sleep(2)
     revdb.stop_point()
     rthread.gc_thread_die()
Пример #2
0
 def bootstrap():
     rthread.gc_thread_start()
     _sleep(1)
     print "BB"
     _sleep(2)
     print "BBB"
     rthread.gc_thread_die()
Пример #3
0
 def bootstrap():
     # Note that when this runs, we already hold the GIL.  This is ensured
     # by rffi's callback mecanism: we are a callback for the
     # c_thread_start() external function.
     rthread.gc_thread_start()
     space = bootstrapper.space
     w_callable = bootstrapper.w_callable
     args = bootstrapper.args
     bootstrapper.nbthreads += 1
     bootstrapper.release()
     # run!
     try:
         bootstrapper.run(space, w_callable, args)
         # done
     except Exception as e:
         # oups! last-level attempt to recover.
         try:
             STDERR = 2
             os.write(STDERR, "Thread exited with ")
             os.write(STDERR, str(e))
             os.write(STDERR, "\n")
         except OSError:
             pass
     bootstrapper.nbthreads -= 1
     rthread.gc_thread_die()
Пример #4
0
 def bootstrap():
     # Note that when this runs, we already hold the GIL.  This is ensured
     # by rffi's callback mecanism: we are a callback for the
     # c_thread_start() external function.
     rthread.gc_thread_start()
     space = bootstrapper.space
     w_callable = bootstrapper.w_callable
     args = bootstrapper.args
     bootstrapper.nbthreads += 1
     bootstrapper.release()
     # run!
     try:
         bootstrapper.run(space, w_callable, args)
         # done
     except Exception as e:
         # oups! last-level attempt to recover.
         try:
             STDERR = 2
             os.write(STDERR, "Thread exited with ")
             os.write(STDERR, str(e))
             os.write(STDERR, "\n")
         except OSError:
             pass
     bootstrapper.nbthreads -= 1
     rthread.gc_thread_die()
Пример #5
0
 def bootstrap():
     rthread.gc_thread_start()
     _sleep(1)
     ec = EC(4567)
     raw_thread_local.set(ec)
     print raw_thread_local.get().value
     assert raw_thread_local.get() is ec
     rthread.gc_thread_die()
Пример #6
0
def PyThreadState_New(space, interp):
    """Create a new thread state object belonging to the given interpreter
    object.  The global interpreter lock need not be held, but may be held if
    it is necessary to serialize calls to this function."""
    if not space.config.translation.thread:
        raise NoThreads
    # PyThreadState_Get will allocate a new execution context,
    # we need to protect gc and other globals with the GIL.
    rthread.gc_thread_start()
    return PyThreadState_Get(space)
Пример #7
0
def PyThreadState_New(space, interp):
    """Create a new thread state object belonging to the given interpreter
    object.  The global interpreter lock need not be held, but may be held if
    it is necessary to serialize calls to this function."""
    if not space.config.translation.thread:
        raise NoThreads
    # PyThreadState_Get will allocate a new execution context,
    # we need to protect gc and other globals with the GIL.
    rthread.gc_thread_start()
    return PyThreadState_Get(space)
Пример #8
0
 def pypy_thread_attach():
     if not space.config.objspace.usemodules.thread:
         return
     os_thread.setup_threads(space)
     os_thread.bootstrapper.acquire(space, None, None)
     rthread.gc_thread_start()
     os_thread.bootstrapper.nbthreads += 1
     os_thread.bootstrapper.release()
     before = rffi.aroundstate.before
     if before: before()
Пример #9
0
 def pypy_thread_attach():
     if not space.config.objspace.usemodules.thread:
         return
     os_thread.setup_threads(space)
     os_thread.bootstrapper.acquire(space, None, None)
     rthread.gc_thread_start()
     os_thread.bootstrapper.nbthreads += 1
     os_thread.bootstrapper.release()
     before = rffi.aroundstate.before
     if before: before()
Пример #10
0
 def pypy_thread_attach():
     if not space.config.objspace.usemodules.thread:
         return
     os_thread.setup_threads(space)
     os_thread.bootstrapper.acquire(space, None, None)
     # XXX this doesn't really work.  Don't use os.fork(), and
     # if your embedder program uses fork(), don't use any PyPy
     # code in the fork
     rthread.gc_thread_start()
     os_thread.bootstrapper.nbthreads += 1
     os_thread.bootstrapper.release()
Пример #11
0
 def bootstrap():
     rthread.gc_thread_start()
     childpid = run_in_thread()
     gc.collect()        # collect both in the child and in the parent
     gc.collect()
     gc.collect()
     if childpid == 0:
         os.write(state.write_end, 'c')   # "I did not die!" from child
     else:
         os.write(state.write_end, 'p')   # "I did not die!" from parent
     rthread.gc_thread_die()
Пример #12
0
 def pypy_thread_attach():
     if not space.config.objspace.usemodules.thread:
         return
     os_thread.setup_threads(space)
     os_thread.bootstrapper.acquire(space, None, None)
     # XXX this doesn't really work.  Don't use os.fork(), and
     # if your embedder program uses fork(), don't use any PyPy
     # code in the fork
     rthread.gc_thread_start()
     os_thread.bootstrapper.nbthreads += 1
     os_thread.bootstrapper.release()
Пример #13
0
 def bootstrap():
     rthread.gc_thread_start()
     childpid = run_in_thread()
     gc.collect()  # collect both in the child and in the parent
     gc.collect()
     gc.collect()
     if childpid == 0:
         os.write(state.write_end, 'c')  # "I did not die!" from child
     else:
         os.write(state.write_end, 'p')  # "I did not die!" from parent
     rthread.gc_thread_die()
Пример #14
0
def PyThreadState_New(space, interp):
    """Create a new thread state object belonging to the given interpreter
    object.  The global interpreter lock need not be held, but may be held if
    it is necessary to serialize calls to this function."""
    rthread.gc_thread_prepare()
    # PyThreadState_Get will allocate a new execution context,
    # we need to protect gc and other globals with the GIL.
    rffi.aroundstate.after()
    try:
        rthread.gc_thread_start()
        return PyThreadState_Get(space)
    finally:
        rffi.aroundstate.before()
Пример #15
0
def bootstrap():
    rthread.gc_thread_start()
    fn = bootstrapper.fn()
    bootstrapper.release()
    fn.invoke([])
    rthread.gc_thread_die()
Пример #16
0
 def bootstrap():
     rthread.gc_thread_start()
     check_errno(42)
     state.xlist.append(Cons(123, Cons(456, None)))
     gc.collect()
     rthread.gc_thread_die()
Пример #17
0
def bootstrap():
    rthread.gc_thread_start()
    fn = bootstrapper.fn()
    bootstrapper.release()
    safe_invoke(fn, [])
    rthread.gc_thread_die()
Пример #18
0
 def bootstrap():
     rthread.gc_thread_start()
     check_errno(42)
     state.xlist.append(Cons(123, Cons(456, None)))
     gc.collect()
     rthread.gc_thread_die()