summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2012-02-29 10:43:00 -0500
committerChris McDonough <chrism@plope.com>2012-02-29 10:43:00 -0500
commitdfdc25447e3eb221eda40492082af89d7363a830 (patch)
treea3eea368c4f447976d07e9f9e63f381a358965b0
parent74c2a098cf92db05ed8f089d95511f1d4f1efa42 (diff)
downloadpyramid-dfdc25447e3eb221eda40492082af89d7363a830.tar.gz
pyramid-dfdc25447e3eb221eda40492082af89d7363a830.tar.bz2
pyramid-dfdc25447e3eb221eda40492082af89d7363a830.zip
fix pserve tests on windows 2.6
-rw-r--r--pyramid/scripts/pserve.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/pyramid/scripts/pserve.py b/pyramid/scripts/pserve.py
index 2bea7376a..8bd6c545c 100644
--- a/pyramid/scripts/pserve.py
+++ b/pyramid/scripts/pserve.py
@@ -9,6 +9,7 @@
# lib/site.py
import atexit
+import ctypes
import errno
import logging
import optparse
@@ -23,10 +24,23 @@ import traceback
from paste.deploy import loadapp, loadserver
+from pyramid.compat import WIN
+
from pyramid.paster import setup_logging
MAXFD = 1024
+if WIN and not hasattr(os, 'kill'): # pragma: no cover
+ # py 2.6 on windows
+ def kill(pid, sig=None):
+ """kill function for Win32"""
+ # signal is ignored
+ kernel32 = ctypes.windll.kernel32
+ handle = kernel32.OpenProcess(1, 0, pid)
+ return (0 != kernel32.TerminateProcess(handle, 0))
+else:
+ kill = os.kill
+
def main(argv=sys.argv, quiet=False):
command = PServeCommand(argv, quiet=quiet)
return command.run()
@@ -451,7 +465,7 @@ class PServeCommand(object):
if not live_pidfile(pid_file):
break
import signal
- os.kill(pid, signal.SIGTERM)
+ kill(pid, signal.SIGTERM)
time.sleep(1)
else:
self.out("failed to kill web process %s" % pid)
@@ -505,11 +519,10 @@ class PServeCommand(object):
raise
return 1
finally:
- if (proc is not None
- and hasattr(os, 'kill')):
+ if proc is not None:
import signal
try:
- os.kill(proc.pid, signal.SIGTERM)
+ kill(proc.pid, signal.SIGTERM)
except (OSError, IOError):
pass
@@ -611,7 +624,7 @@ def live_pidfile(pidfile): # pragma: no cover
pid = read_pidfile(pidfile)
if pid:
try:
- os.kill(int(pid), 0)
+ kill(int(pid), 0)
return pid
except OSError as e:
if e.errno == errno.EPERM: