Make sure that we get the default signal handler for test_asyncio,
The parent process may have decided to ignore SIGHUP, and signal handlers are inherited which can cause the test to hang in koji.
This commit is contained in:
parent
5b6a3e0e34
commit
3a226ae7d7
99
00271-asyncio-get-default-signal-handler.patch
Normal file
99
00271-asyncio-get-default-signal-handler.patch
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
|
||||||
|
index 492a84a2313..9746678607c 100644
|
||||||
|
--- a/Lib/test/test_asyncio/test_events.py
|
||||||
|
+++ b/Lib/test/test_asyncio/test_events.py
|
||||||
|
@@ -1980,19 +1980,26 @@ def test_subprocess_terminate(self):
|
||||||
|
|
||||||
|
@unittest.skipIf(sys.platform == 'win32', "Don't have SIGHUP")
|
||||||
|
def test_subprocess_send_signal(self):
|
||||||
|
- prog = os.path.join(os.path.dirname(__file__), 'echo.py')
|
||||||
|
-
|
||||||
|
- connect = self.loop.subprocess_exec(
|
||||||
|
- functools.partial(MySubprocessProtocol, self.loop),
|
||||||
|
- sys.executable, prog)
|
||||||
|
- transp, proto = self.loop.run_until_complete(connect)
|
||||||
|
- self.assertIsInstance(proto, MySubprocessProtocol)
|
||||||
|
- self.loop.run_until_complete(proto.connected)
|
||||||
|
-
|
||||||
|
- transp.send_signal(signal.SIGHUP)
|
||||||
|
- self.loop.run_until_complete(proto.completed)
|
||||||
|
- self.assertEqual(-signal.SIGHUP, proto.returncode)
|
||||||
|
- transp.close()
|
||||||
|
+ # bpo-31034: Make sure that we get the default signal handler (killing
|
||||||
|
+ # the process). The parent process may have decided to ignore SIGHUP,
|
||||||
|
+ # and signal handlers are inherited.
|
||||||
|
+ old_handler = signal.signal(signal.SIGHUP, signal.SIG_DFL)
|
||||||
|
+ try:
|
||||||
|
+ prog = os.path.join(os.path.dirname(__file__), 'echo.py')
|
||||||
|
+
|
||||||
|
+ connect = self.loop.subprocess_exec(
|
||||||
|
+ functools.partial(MySubprocessProtocol, self.loop),
|
||||||
|
+ sys.executable, prog)
|
||||||
|
+ transp, proto = self.loop.run_until_complete(connect)
|
||||||
|
+ self.assertIsInstance(proto, MySubprocessProtocol)
|
||||||
|
+ self.loop.run_until_complete(proto.connected)
|
||||||
|
+
|
||||||
|
+ transp.send_signal(signal.SIGHUP)
|
||||||
|
+ self.loop.run_until_complete(proto.completed)
|
||||||
|
+ self.assertEqual(-signal.SIGHUP, proto.returncode)
|
||||||
|
+ transp.close()
|
||||||
|
+ finally:
|
||||||
|
+ signal.signal(signal.SIGHUP, old_handler)
|
||||||
|
|
||||||
|
def test_subprocess_stderr(self):
|
||||||
|
prog = os.path.join(os.path.dirname(__file__), 'echo2.py')
|
||||||
|
diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py
|
||||||
|
index 2e14a8a9735..e8822c36698 100644
|
||||||
|
--- a/Lib/test/test_asyncio/test_subprocess.py
|
||||||
|
+++ b/Lib/test/test_asyncio/test_subprocess.py
|
||||||
|
@@ -166,25 +166,32 @@ def test_terminate(self):
|
||||||
|
|
||||||
|
@unittest.skipIf(sys.platform == 'win32', "Don't have SIGHUP")
|
||||||
|
def test_send_signal(self):
|
||||||
|
- code = 'import time; print("sleeping", flush=True); time.sleep(3600)'
|
||||||
|
- args = [sys.executable, '-c', code]
|
||||||
|
- create = asyncio.create_subprocess_exec(*args,
|
||||||
|
- stdout=subprocess.PIPE,
|
||||||
|
- loop=self.loop)
|
||||||
|
- proc = self.loop.run_until_complete(create)
|
||||||
|
-
|
||||||
|
- @asyncio.coroutine
|
||||||
|
- def send_signal(proc):
|
||||||
|
- # basic synchronization to wait until the program is sleeping
|
||||||
|
- line = yield from proc.stdout.readline()
|
||||||
|
- self.assertEqual(line, b'sleeping\n')
|
||||||
|
+ # bpo-31034: Make sure that we get the default signal handler (killing
|
||||||
|
+ # the process). The parent process may have decided to ignore SIGHUP,
|
||||||
|
+ # and signal handlers are inherited.
|
||||||
|
+ old_handler = signal.signal(signal.SIGHUP, signal.SIG_DFL)
|
||||||
|
+ try:
|
||||||
|
+ code = 'import time; print("sleeping", flush=True); time.sleep(3600)'
|
||||||
|
+ args = [sys.executable, '-c', code]
|
||||||
|
+ create = asyncio.create_subprocess_exec(*args,
|
||||||
|
+ stdout=subprocess.PIPE,
|
||||||
|
+ loop=self.loop)
|
||||||
|
+ proc = self.loop.run_until_complete(create)
|
||||||
|
|
||||||
|
- proc.send_signal(signal.SIGHUP)
|
||||||
|
- returncode = (yield from proc.wait())
|
||||||
|
- return returncode
|
||||||
|
-
|
||||||
|
- returncode = self.loop.run_until_complete(send_signal(proc))
|
||||||
|
- self.assertEqual(-signal.SIGHUP, returncode)
|
||||||
|
+ @asyncio.coroutine
|
||||||
|
+ def send_signal(proc):
|
||||||
|
+ # basic synchronization to wait until the program is sleeping
|
||||||
|
+ line = yield from proc.stdout.readline()
|
||||||
|
+ self.assertEqual(line, b'sleeping\n')
|
||||||
|
+
|
||||||
|
+ proc.send_signal(signal.SIGHUP)
|
||||||
|
+ returncode = (yield from proc.wait())
|
||||||
|
+ return returncode
|
||||||
|
+
|
||||||
|
+ returncode = self.loop.run_until_complete(send_signal(proc))
|
||||||
|
+ self.assertEqual(-signal.SIGHUP, returncode)
|
||||||
|
+ finally:
|
||||||
|
+ signal.signal(signal.SIGHUP, old_handler)
|
||||||
|
|
||||||
|
def prepare_broken_pipe_test(self):
|
||||||
|
# buffer large enough to feed the whole pipe buffer
|
12
python3.spec
12
python3.spec
@ -133,7 +133,7 @@
|
|||||||
Summary: Version 3 of the Python programming language aka Python 3000
|
Summary: Version 3 of the Python programming language aka Python 3000
|
||||||
Name: python3
|
Name: python3
|
||||||
Version: %{pybasever}.2
|
Version: %{pybasever}.2
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
License: Python
|
License: Python
|
||||||
Group: Development/Languages
|
Group: Development/Languages
|
||||||
|
|
||||||
@ -444,6 +444,12 @@ Patch264: 00264-skip-test-failing-on-aarch64.patch
|
|||||||
# Fixed upstream: http://bugs.python.org/issue30714
|
# Fixed upstream: http://bugs.python.org/issue30714
|
||||||
Patch270: 00270-fix-ssl-alpn-hook-test.patch
|
Patch270: 00270-fix-ssl-alpn-hook-test.patch
|
||||||
|
|
||||||
|
# 00271 #
|
||||||
|
# Make test_asyncio to not depend on the current signal handler
|
||||||
|
# as this can make it hang on koji, since it ignores SIGHUP.
|
||||||
|
# Reported upstream: http://bugs.python.org/issue31034
|
||||||
|
Patch271: 00271-asyncio-get-default-signal-handler.patch
|
||||||
|
|
||||||
# (New patches go here ^^^)
|
# (New patches go here ^^^)
|
||||||
#
|
#
|
||||||
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
|
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
|
||||||
@ -717,6 +723,7 @@ sed -r -i s/'_PIP_VERSION = "[0-9.]+"'/'_PIP_VERSION = "%{pip_version}"'/ Lib/en
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%patch270 -p1
|
%patch270 -p1
|
||||||
|
%patch271 -p1
|
||||||
|
|
||||||
# Currently (2010-01-15), http://docs.python.org/library is for 2.6, and there
|
# Currently (2010-01-15), http://docs.python.org/library is for 2.6, and there
|
||||||
# are many differences between 2.6 and the Python 3 library.
|
# are many differences between 2.6 and the Python 3 library.
|
||||||
@ -1680,6 +1687,9 @@ fi
|
|||||||
# ======================================================
|
# ======================================================
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Jul 25 2017 Charalampos Stratakis <cstratak@redhat.com> - 3.6.2-2
|
||||||
|
- Make test_asyncio to not depend on the current SIGHUP signal handler.
|
||||||
|
|
||||||
* Tue Jul 18 2017 Charalampos Stratakis <cstratak@redhat.com> - 3.6.2-1
|
* Tue Jul 18 2017 Charalampos Stratakis <cstratak@redhat.com> - 3.6.2-1
|
||||||
- Update to Python 3.6.2
|
- Update to Python 3.6.2
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user