New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
win32 iptest: Use subprocess.Popen() instead of os.system(). #2148
Conversation
Will do, but it might not be until c 25 July. |
def _kill(pid): | ||
"""Attempt to kill the process on a best effort basis.""" | ||
if hasattr(os, 'kill'): | ||
os.kill(pid, signal.SIGKILL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows doesn't have signal.SIGKILL (TERM is equivalent to KILL on Windows).
Perhaps reorganizing a bit so that you are calling the p.terminate() / p.kill() methods on the Popen object itself, which hide the platform differences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, thanks for the update. Is there a kill or terminate method on Popen objects in Python 2.6 in Windows?
Might be time for me to dig out an old copy of windows xp for testing....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the kill/terminate methods should be defined everywhere we run, and on Windows kill is just an alias to terminate:
http://docs.python.org/library/subprocess.html#subprocess.Popen.terminate
I can take a look on sunday |
I ran the testsuite with python 2.7 without errors. I got one failure on python 3.2 but I suspect it is not related to this PR Has anyone else seen this?
|
I've seen that, I think it's just a leftover in the installation from when we had a separate Python 3 profile. If you remove the installation and clear the |
Following takluyver's suggestion the tests pass on python3.2 as well. |
All tests pass on WinXP, Python 2.7, except for (unrelated) gh-2018 |
OK, thanks everyone for the windows testing, will merge now as code otherwise looks solid. Thanks, @bfroehle for this cleanup! |
win32 iptest: Use subprocess.Popen() instead of os.system(). The call to `os.system` in `iptest` prevents us from easily setting `$IPYTHONDIR` to a temporary directory. In theory we should be able to use `subprocess.Popen` instead of `os.system` in Windows. This would unify the code structure and make it easy to pass in a different environment. Note that Python < 2.7 does not have `os.kill`. I've attempted to work around this by using `ctypes` to kill any living processes.
Why did this get merged without addressing the comments about using the Popen methods for terminate/kill? This does not work on Win7, due to an AttributeError on signal.SIGKILL. |
On Wed, Jul 25, 2012 at 11:40 AM, Min RK
ouch, my fault. I misread the discussion... Will try to whip up something now. |
@minrk: Is that what you had in mind for dealing with a lack of signal.SIGKILL in win32: bfroehle/fix_os_kill_win32 |
Precisely, yes. |
Fixes iptest brokenness caused by ipython#2148.
Create a unique & temporary IPYTHONDIR for each testing group. Following #2148 (unification of Windows / Unix code in iptest), and in progress towards #1880 (Add parallelism to iptest & test_pr), this pull request launches each iptest test group with a unique & temporary `IPYTHONDIR`. This has two benefits: * Insulates the test suite from any craziness in your own configuration. (Try adding `import sys; sys.exit()` to your config file...). * Allows multiple test suites to be launched in parallel without the worry of conflicts.
win32 iptest: Use subprocess.Popen() instead of os.system(). The call to `os.system` in `iptest` prevents us from easily setting `$IPYTHONDIR` to a temporary directory. In theory we should be able to use `subprocess.Popen` instead of `os.system` in Windows. This would unify the code structure and make it easy to pass in a different environment. Note that Python < 2.7 does not have `os.kill`. I've attempted to work around this by using `ctypes` to kill any living processes.
Fixes iptest brokenness caused by ipython#2148.
Work around lack of os.kill in win32. Fixes iptest brokenness on win32 caused by my having merged ipython#2148 too hastily. Extra credit to @bfroehle and @minrk for working/testing the fix quickly.
Create a unique & temporary IPYTHONDIR for each testing group. Following ipython#2148 (unification of Windows / Unix code in iptest), and in progress towards ipython#1880 (Add parallelism to iptest & test_pr), this pull request launches each iptest test group with a unique & temporary `IPYTHONDIR`. This has two benefits: * Insulates the test suite from any craziness in your own configuration. (Try adding `import sys; sys.exit()` to your config file...). * Allows multiple test suites to be launched in parallel without the worry of conflicts.
(Do not merge, needs testing in Windows).
The call to
os.system
iniptest
prevents us from easily setting$IPYTHONDIR
to a temporary directory. In theory we should be able to usesubprocess.Popen
instead ofos.system
in Windows. This would unify the code structure and make it easy to pass in a different environment.Note that Python < 2.7 does not have
os.kill
. I've attempted to work around this by usingctypes
to kill any living processes.I haven't actually tested any of this in Windows. Perhaps @jdmarch or @jstenar or somebody else using windows could run some tests with it.