[pypy-commit] pypy py3k: Add _thread.TIMEOUT_MAX. Not used for now

amauryfa noreply at buildbot.pypy.org
Sat Oct 22 23:03:17 CEST 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r48347:2e215c92d5ba
Date: 2011-10-22 11:49 +0200
http://bitbucket.org/pypy/pypy/changeset/2e215c92d5ba/

Log:	Add _thread.TIMEOUT_MAX. Not used for now

diff --git a/pypy/module/thread/__init__.py b/pypy/module/thread/__init__.py
--- a/pypy/module/thread/__init__.py
+++ b/pypy/module/thread/__init__.py
@@ -21,6 +21,7 @@
         'allocate':               'os_lock.allocate_lock',  # obsolete synonym
         'LockType':               'os_lock.Lock',
         '_local':                 'os_local.Local',
+        'TIMEOUT_MAX':            'space.wrap(float(os_lock.TIMEOUT_MAX) / 1000000.0)',
         'error':                  'space.fromcache(error.Cache).w_error',
     }
 
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
@@ -7,10 +7,14 @@
 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.typedef import TypeDef
+from pypy.rlib.rarithmetic import r_longlong
 
 # Force the declaration of the type 'thread.LockType' for RPython
 #import pypy.module.thread.rpython.exttable
 
+LONGLONG_MAX = r_longlong(2 ** (r_longlong.BITS-1) - 1)
+TIMEOUT_MAX = LONGLONG_MAX
+
 
 ##import sys
 ##def debug(msg, n):
@@ -113,4 +117,4 @@
 def allocate_lock(space):
     """Create a new lock object.  (allocate() is an obsolete synonym.)
 See LockType.__doc__ for information about locks."""
-    return space.wrap(Lock(space))
\ No newline at end of file
+    return space.wrap(Lock(space))
diff --git a/pypy/module/thread/test/test_lock.py b/pypy/module/thread/test/test_lock.py
--- a/pypy/module/thread/test/test_lock.py
+++ b/pypy/module/thread/test/test_lock.py
@@ -46,6 +46,12 @@
             assert feedback == [42]
         assert lock.locked() is False
 
+    def test_timeout(self):
+        import _thread
+        assert isinstance(_thread.TIMEOUT_MAX, float)
+        assert _thread.TIMEOUT_MAX > 1000
+
+
 def test_compile_lock():
     from pypy.rlib import rgc
     from pypy.module.thread.ll_thread import allocate_lock


More information about the pypy-commit mailing list