Author: Armin Rigo <[email protected]>
Branch:
Changeset: r61231:adadaf3b93c0
Date: 2013-02-14 15:06 +0100
http://bitbucket.org/pypy/pypy/changeset/adadaf3b93c0/
Log: Fix the imports: instead of "import rthread as thread", use the name
"rthread" throughout the files, which is less confusing.
diff --git a/pypy/module/thread/gil.py b/pypy/module/thread/gil.py
--- a/pypy/module/thread/gil.py
+++ b/pypy/module/thread/gil.py
@@ -7,7 +7,7 @@
# all but one will be blocked. The other threads get a chance to run
# from time to time, using the periodic action GILReleaseAction.
-from rpython.rlib import rthread as thread
+from rpython.rlib import rthread
from pypy.module.thread.error import wrap_thread_error
from pypy.interpreter.executioncontext import PeriodicAsyncAction
from pypy.module.thread.threadlocals import OSThreadLocals
@@ -25,7 +25,7 @@
use_bytecode_counter=True)
def _initialize_gil(self, space):
- if not thread.gil_allocate():
+ if not rthread.gil_allocate():
raise wrap_thread_error(space, "can't allocate GIL")
def setup_threads(self, space):
@@ -72,15 +72,15 @@
# this function must not raise, in such a way that the exception
# transformer knows that it cannot raise!
e = get_errno()
- thread.gil_release()
+ rthread.gil_release()
set_errno(e)
before_external_call._gctransformer_hint_cannot_collect_ = True
before_external_call._dont_reach_me_in_del_ = True
def after_external_call():
e = get_errno()
- thread.gil_acquire()
- thread.gc_thread_run()
+ rthread.gil_acquire()
+ rthread.gc_thread_run()
after_thread_switch()
set_errno(e)
after_external_call._gctransformer_hint_cannot_collect_ = True
@@ -97,8 +97,8 @@
# explicitly release the gil, in a way that tries to give more
# priority to other threads (as opposed to continuing to run in
# the same thread).
- if thread.gil_yield_thread():
- thread.gc_thread_run()
+ if rthread.gil_yield_thread():
+ rthread.gc_thread_run()
after_thread_switch()
do_yield_thread._gctransformer_hint_close_stack_ = True
do_yield_thread._dont_reach_me_in_del_ = True
diff --git a/pypy/module/thread/os_lock.py b/pypy/module/thread/os_lock.py
--- a/pypy/module/thread/os_lock.py
+++ b/pypy/module/thread/os_lock.py
@@ -2,15 +2,12 @@
Python locks, based on true threading locks provided by the OS.
"""
-from rpython.rlib import rthread as thread
+from rpython.rlib import rthread
from pypy.module.thread.error import wrap_thread_error
from pypy.interpreter.baseobjspace import Wrappable
from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.typedef import TypeDef
-# Force the declaration of the type 'thread.LockType' for RPython
-#import pypy.module.thread.rpython.exttable
-
##import sys
##def debug(msg, n):
@@ -22,7 +19,7 @@
## except:
## pass
## tb = ' '.join(tb)
-## msg = '| %6d | %d %s | %s\n' % (thread.get_ident(), n, msg, tb)
+## msg = '| %6d | %d %s | %s\n' % (rthread.get_ident(), n, msg, tb)
## sys.stderr.write(msg)
@@ -32,8 +29,8 @@
def __init__(self, space):
self.space = space
try:
- self.lock = thread.allocate_lock()
- except thread.error:
+ self.lock = rthread.allocate_lock()
+ except rthread.error:
raise wrap_thread_error(space, "out of resources")
@unwrap_spec(waitflag=int)
@@ -54,7 +51,7 @@
but it needn't be locked by the same thread that unlocks it."""
try:
self.lock.release()
- except thread.error:
+ except rthread.error:
raise wrap_thread_error(space, "release unlocked lock")
def descr_lock_locked(self, space):
diff --git a/pypy/module/thread/os_thread.py b/pypy/module/thread/os_thread.py
--- a/pypy/module/thread/os_thread.py
+++ b/pypy/module/thread/os_thread.py
@@ -3,7 +3,7 @@
"""
import os
-from rpython.rlib import rthread as thread
+from rpython.rlib import rthread
from pypy.module.thread.error import wrap_thread_error
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.gateway import unwrap_spec, Arguments
@@ -65,8 +65,8 @@
def setup(space):
if bootstrapper.lock is None:
try:
- bootstrapper.lock = thread.allocate_lock()
- except thread.error:
+ bootstrapper.lock = rthread.allocate_lock()
+ except rthread.error:
raise wrap_thread_error(space, "can't allocate bootstrap lock")
@staticmethod
@@ -83,7 +83,7 @@
# 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.
- thread.gc_thread_start()
+ rthread.gc_thread_start()
space = bootstrapper.space
w_callable = bootstrapper.w_callable
args = bootstrapper.args
@@ -103,7 +103,7 @@
except OSError:
pass
bootstrapper.nbthreads -= 1
- thread.gc_thread_die()
+ rthread.gc_thread_die()
bootstrap = staticmethod(bootstrap)
def acquire(space, w_callable, args):
@@ -130,7 +130,7 @@
space.call_args(w_callable, args)
except OperationError, e:
if not e.match(space, space.w_SystemExit):
- ident = thread.get_ident()
+ ident = rthread.get_ident()
where = 'thread %d started by ' % ident
e.write_unraisable(space, where, w_callable)
e.clear(space)
@@ -150,7 +150,7 @@
"Called in the child process after a fork()"
space.threadlocals.reinit_threads(space)
bootstrapper.reinit()
- thread.thread_after_fork()
+ rthread.thread_after_fork()
# Clean the threading module after a fork()
w_modules = space.sys.get('modules')
@@ -181,12 +181,12 @@
bootstrapper.acquire(space, w_callable, args)
try:
try:
- thread.gc_thread_prepare() # (this has no effect any more)
- ident = thread.start_new_thread(bootstrapper.bootstrap, ())
+ rthread.gc_thread_prepare() # (this has no effect any more)
+ ident = rthread.start_new_thread(bootstrapper.bootstrap, ())
except Exception, e:
bootstrapper.release() # normally called by the new thread
raise
- except thread.error:
+ except rthread.error:
raise wrap_thread_error(space, "can't start new thread")
return space.wrap(ident)
@@ -199,7 +199,7 @@
allocated consecutive numbers starting at 1, this behavior should not
be relied upon, and the number should be seen purely as a magic cookie.
A thread's identity may be reused for another thread after it exits."""
- ident = thread.get_ident()
+ ident = rthread.get_ident()
return space.wrap(ident)
@unwrap_spec(size=int)
@@ -225,8 +225,8 @@
if size < 0:
raise OperationError(space.w_ValueError,
space.wrap("size must be 0 or a positive value"))
- old_size = thread.get_stacksize()
- error = thread.set_stacksize(size)
+ old_size = rthread.get_stacksize()
+ error = rthread.set_stacksize(size)
if error == -1:
raise operationerrfmt(space.w_ValueError,
"size not valid: %d bytes", size)
diff --git a/pypy/module/thread/threadlocals.py
b/pypy/module/thread/threadlocals.py
--- a/pypy/module/thread/threadlocals.py
+++ b/pypy/module/thread/threadlocals.py
@@ -1,4 +1,4 @@
-from rpython.rlib import rthread as thread
+from rpython.rlib import rthread
class OSThreadLocals:
@@ -18,7 +18,7 @@
self._mostrecentvalue = None # fast minicaching for the common case
def getvalue(self):
- ident = thread.get_ident()
+ ident = rthread.get_ident()
if ident == self._mostrecentkey:
result = self._mostrecentvalue
else:
@@ -30,7 +30,7 @@
return result
def setvalue(self, value):
- ident = thread.get_ident()
+ ident = rthread.get_ident()
if value is not None:
if len(self._valuedict) == 0:
self._mainthreadident = ident
@@ -45,7 +45,7 @@
self._mostrecentvalue = value
def ismainthread(self):
- return thread.get_ident() == self._mainthreadident
+ return rthread.get_ident() == self._mainthreadident
def getallvalues(self):
return self._valuedict
@@ -60,4 +60,4 @@
def reinit_threads(self, space):
"Called in the child process after a fork()"
- self._mainthreadident = thread.get_ident()
+ self._mainthreadident = rthread.get_ident()
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit