[Python-checkins] cpython (merge 3.6 -> default): Issue #26939: Merge 3.6.

xavier.degaye python-checkins at python.org
Thu Dec 8 05:10:34 EST 2016


https://hg.python.org/cpython/rev/c5d7e46926ac
changeset:   105523:c5d7e46926ac
parent:      105521:1afc3f4f5502
parent:      105522:fd1718badb67
user:        Xavier de Gaye <xdegaye at users.sourceforge.net>
date:        Thu Dec 08 11:09:54 2016 +0100
summary:
  Issue #26939: Merge 3.6.

files:
  Lib/test/support/__init__.py |  16 ++++++++++++++++
  Lib/test/test_functools.py   |   2 +-
  Misc/NEWS                    |   3 +++
  3 files changed, 20 insertions(+), 1 deletions(-)


diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -93,6 +93,7 @@
     "check__all__", "requires_android_level", "requires_multiprocessing_queue",
     # sys
     "is_jython", "is_android", "check_impl_detail", "unix_shell",
+    "setswitchinterval",
     # network
     "HOST", "IPV6_ENABLED", "find_unused_port", "bind_port", "open_urlresource",
     # processes
@@ -2552,3 +2553,18 @@
             continue
         if spawn.find_executable(cmd[0]) is None:
             return cmd[0]
+
+
+_is_android_emulator = None
+def setswitchinterval(interval):
+    # Setting a very low gil interval on the Android emulator causes python
+    # to hang (issue #26939).
+    minimum_interval = 1e-5
+    if is_android and interval < minimum_interval:
+        global _is_android_emulator
+        if _is_android_emulator is None:
+            _is_android_emulator = (subprocess.check_output(
+                               ['getprop', 'ro.kernel.qemu']).strip() == b'1')
+        if _is_android_emulator:
+            interval = minimum_interval
+    return sys.setswitchinterval(interval)
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -1322,7 +1322,7 @@
                 f.cache_clear()
 
         orig_si = sys.getswitchinterval()
-        sys.setswitchinterval(1e-6)
+        support.setswitchinterval(1e-6)
         try:
             # create n threads in order to fill cache
             threads = [threading.Thread(target=full, args=[k])
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -579,6 +579,9 @@
 
 - Issue #28217: Adds _testconsole module to test console input.
 
+- Issue #26939: Add the support.setswitchinterval() function to fix
+  test_functools hanging on the Android armv7 qemu emulator.
+
 
 What's New in Python 3.6.0 beta 1
 =================================

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list