cpython: fd1718badb67 (original) (raw)
Mercurial > cpython
changeset 105522:fd1718badb67 3.6
Issue #26939: Add the support.setswitchinterval() function to fix test_functools hanging on the Android armv7 qemu emulator. [#26939]
Xavier de Gaye xdegaye@users.sourceforge.net | |
---|---|
date | Thu, 08 Dec 2016 11:06:56 +0100 |
parents | 4745d801cae2 |
children | c5d7e46926ac 1bb2f4b8440e |
files | Lib/test/support/__init__.py Lib/test/test_functools.py Misc/NEWS |
diffstat | 3 files changed, 23 insertions(+), 1 deletions(-)[+] [-] Lib/test/support/__init__.py 16 Lib/test/test_functools.py 2 Misc/NEWS 6 |
line wrap: on
line diff
--- a/Lib/test/support/init.py +++ b/Lib/test/support/init.py @@ -93,6 +93,7 @@ except ImportError: "check__all__", "requires_android_level", "requires_multiprocessing_queue", # sys "is_jython", "is_android", "check_impl_detail", "unix_shell",
- "setswitchinterval",
"HOST", "IPV6_ENABLED", "find_unused_port", "bind_port", "open_urlresource", network
processes
@@ -2547,3 +2548,18 @@ def missing_compiler_executable(cmd_name 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[](#l1.23)
if _is_android_emulator is None:[](#l1.24)
_is_android_emulator = (subprocess.check_output([](#l1.25)
['getprop', 'ro.kernel.qemu']).strip() == b'1')[](#l1.26)
if _is_android_emulator:[](#l1.27)
interval = minimum_interval[](#l1.28)
- return sys.setswitchinterval(interval)
--- 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)[](#l2.7)
support.setswitchinterval(1e-6)[](#l2.8) try:[](#l2.9) # create n threads in order to fill cache[](#l2.10) threads = [threading.Thread(target=full, args=[k])[](#l2.11)