classification
Title: subprocess unit tests for kill, term and send_signal flaky
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: benjamin.peterson, brian.curtin, christian.heimes, ezio.melotti, flox
Priority: critical Keywords: needs review, patch

Created on 2008-05-06 23:40 by christian.heimes, last changed 2010-03-08 14:26 by flox. This issue is now closed.

Files
File name Uploaded Description Edit
issue2777.patch brian.curtin, 2010-01-07 20:22 patch against trunk r77358
Messages (11)
msg66347 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-05-06 23:40
The unit tests for the kill, term and send_signal methods of the
subprocess.Popen object are still flaky and sometimes cause the test
suite to hang. I'm going to disable them for the upcoming alpha until
I've found a better solution.
msg70356 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-07-28 16:59
What's the status of this?
msg95157 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2009-11-12 05:07
I re-enabled the tests a few days ago and haven't seen any issues on
Windows or Linux. I attached a patch against r76222 which enables the
kill, term, and send_signal tests again, and also did some clean-up and
updating to the way tests are skipped.

I also changed the assertNotEqual at the end of the kill, term, and
send_signal tests to check against None instead of 0. I *think* it
should be checking against None there to make sure that the subprocess
isn't live anymore (where None would mean that it is).

Let me know what you think and if this needs anything else.
msg97370 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-01-07 20:22
Minor patch change
msg99042 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-02-08 11:18
The patch looks fine.
+1 to enable on trunk and follow the buildbots' behavior.
msg100189 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-02-27 17:57
Patch based on Brian's patch, with additional cleanup, and use new unittest helpers: skipUnless, assertRaises.

And create a custom helper assertStderrEqual instead of "remove_stderr_debug_decorations" for debug builds.
msg100190 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-02-27 19:24
Cleanup patch applied on r78508.
I will probably try to enable the tests on trunk.
msg100420 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-03-04 20:59
I experienced this hang with Linux AMD64.

It occurs in test_send_signal.
It is because signal.SIGINT is not always handled (see #3137).

As a workaround, there's 2 choices: add a delay between Popen and send_signal, or retry SIGINT 2 or 3 times.

Windows should not be affected, because it uses signal SIGTERM in the test.
msg100425 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-03-04 22:13
Re-enabled on r78662 and r78663.
Buildbots seems happy, except Windows XP + Cygwin buildbot:

======================================================================
FAIL: test_kill (test.test_subprocess.Win32ProcessTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\cygwin\home\db3l\buildarea\trunk.bolen-windows\build\lib\test\test_subprocess.py", line 768, in test_kill
    self.assertNotEqual(p.wait(), 0)
AssertionError: 0 == 0

======================================================================
FAIL: test_send_signal (test.test_subprocess.Win32ProcessTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\cygwin\home\db3l\buildarea\trunk.bolen-windows\build\lib\test\test_subprocess.py", line 761, in test_send_signal
    self.assertNotEqual(p.wait(), 0)
AssertionError: 0 == 0

======================================================================
FAIL: test_terminate (test.test_subprocess.Win32ProcessTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\cygwin\home\db3l\buildarea\trunk.bolen-windows\build\lib\test\test_subprocess.py", line 775, in test_terminate
    self.assertNotEqual(p.wait(), 0)
AssertionError: 0 == 0
msg100440 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-03-04 23:49
...and it hangs somewhere on ia64 Ubuntu.
http://www.python.org/dev/buildbot/all/builders/ia64%20Ubuntu%203.x/builds/557
msg100645 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-03-08 14:26
All this flakiness is fixed:
 - r78736, r78759, r78761, r78767, r78788, r78789 on 2.x
 - r78797 on 3.x


Note: because of #3137, the send_signal(SIGINT) is retried 2 times on some platforms.
History
Date User Action Args
2010-03-08 14:26:06floxsetstatus: open -> closed
resolution: fixed
messages: + msg100645

stage: patch review -> resolved
2010-03-04 23:49:54floxsetmessages: + msg100440
2010-03-04 22:13:54floxsetmessages: + msg100425
2010-03-04 20:59:00floxsetmessages: + msg100420
2010-02-27 19:25:16floxsetfiles: - issue2777_clean_test_subprocess.diff
2010-02-27 19:24:41floxsetmessages: + msg100190
2010-02-27 17:58:16floxsetfiles: + issue2777_clean_test_subprocess.diff
2010-02-27 17:57:52floxsetnosy: + ezio.melotti
messages: + msg100189
2010-02-08 11:18:29floxsetmessages: + msg99042
2010-02-08 10:17:37floxsetnosy: + flox
2010-01-07 20:22:26brian.curtinsetfiles: + issue2777.patch
versions: + Python 3.1, Python 2.7, Python 3.2, - Python 3.0
messages: + msg97370

keywords: + needs review
stage: patch review
2010-01-07 20:19:29brian.curtinsetfiles: - issue2777.patch
2009-11-12 05:07:26brian.curtinsetfiles: + issue2777.patch

nosy: + brian.curtin
messages: + msg95157

keywords: + patch
2008-07-28 16:59:36benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg70356
2008-05-06 23:40:54christian.heimescreate