summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier de Gaye <xdegaye@users.sourceforge.net>2016-12-08 10:06:56 (GMT)
committerXavier de Gaye <xdegaye@users.sourceforge.net>2016-12-08 10:06:56 (GMT)
commit7522ef402c324481fabd841a89810fd944cd3cec (patch)
tree38fbf75e9d4d65c0273beef7bc571c99eb9981a9
parent0d5742dec0a44c6fdbb544bc683855ff78554e72 (diff)
downloadcpython-7522ef402c324481fabd841a89810fd944cd3cec.zip
cpython-7522ef402c324481fabd841a89810fd944cd3cec.tar.gz
cpython-7522ef402c324481fabd841a89810fd944cd3cec.tar.bz2
Issue #26939: Add the support.setswitchinterval() function to fix
test_functools hanging on the Android armv7 qemu emulator.
-rw-r--r--Lib/test/support/__init__.py16
-rw-r--r--Lib/test/test_functools.py2
-rw-r--r--Misc/NEWS6
3 files changed, 23 insertions, 1 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 1e27777..fa344ec 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -93,6 +93,7 @@ __all__ = [
"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
@@ -2547,3 +2548,18 @@ def missing_compiler_executable(cmd_names=[]):
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
index 75427df..ba2a52f 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -1322,7 +1322,7 @@ class TestLRU:
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
index 8023df3..a15bb9b 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -22,6 +22,12 @@ Library
- Issue #28847: dbm.dumb now supports reading read-only files and no longer
writes the index file when it is not changed.
+Tests
+-----
+
+- 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 release candidate 1
==============================================