Author: Brian Kearns <bdkea...@gmail.com> Branch: Changeset: r71157:0022e98eb8d3 Date: 2014-05-01 18:06 -0400 http://bitbucket.org/pypy/pypy/changeset/0022e98eb8d3/
Log: merge heads diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py --- a/pypy/interpreter/baseobjspace.py +++ b/pypy/interpreter/baseobjspace.py @@ -692,23 +692,17 @@ def allocate_lock(self): """Return an interp-level Lock object if threads are enabled, and a dummy object if they are not.""" - if self.config.objspace.usemodules.thread: - # we use a sub-function to avoid putting the 'import' statement - # here, where the flow space would see it even if thread=False - return self.__allocate_lock() - else: - return dummy_lock - - def __allocate_lock(self): - from rpython.rlib.rthread import allocate_lock, error + from rpython.rlib import rthread + if not self.config.objspace.usemodules.thread: + return rthread.dummy_lock # hack: we can't have prebuilt locks if we're translating. # In this special situation we should just not lock at all # (translation is not multithreaded anyway). if not we_are_translated() and self.config.translating: raise CannotHaveLock() try: - return allocate_lock() - except error: + return rthread.allocate_lock() + except rthread.error: raise OperationError(self.w_RuntimeError, self.wrap("out of resources")) @@ -1722,24 +1716,6 @@ return space.getitem(w_glob, space.wrap('anonymous')) -class DummyLock(object): - def acquire(self, flag): - return True - - def release(self): - pass - - def _freeze_(self): - return True - - def __enter__(self): - pass - - def __exit__(self, *args): - pass - -dummy_lock = DummyLock() - # Table describing the regular part of the interface of object spaces, # namely all methods which only take w_ arguments and return a w_ result # (if any). diff --git a/rpython/rlib/rthread.py b/rpython/rlib/rthread.py --- a/rpython/rlib/rthread.py +++ b/rpython/rlib/rthread.py @@ -1,4 +1,3 @@ - from rpython.rtyper.lltypesystem import rffi, lltype, llmemory from rpython.translator.tool.cbuild import ExternalCompilationInfo from rpython.conftest import cdir @@ -113,6 +112,24 @@ assert len(y) == 0 return rffi.cast(lltype.Signed, ll_start_new_thread(x)) +class DummyLock(object): + def acquire(self, flag): + return True + + def release(self): + pass + + def _freeze_(self): + return True + + def __enter__(self): + pass + + def __exit__(self, *args): + pass + +dummy_lock = DummyLock() + class Lock(object): """ Container for low-level implementation of a lock object _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit