# HG changeset patch # User Christian Ebert # Date 1309524734 -7200 # Node ID 0d4e44410b4dcf0466848b28fc6ffe64d6d7933d # Parent 1f47c6ec53d61a034fca38b21bfe4b4491e47ca3# Parent 87b7569d740486da7d4fd3636d49e9ace5082799 Merge with stable diff -r 1f47c6ec53d6 -r 0d4e44410b4d tests/run-tests.py --- a/tests/run-tests.py Mon Jun 20 12:02:52 2011 +0200 +++ b/tests/run-tests.py Fri Jul 01 14:52:14 2011 +0200 @@ -78,10 +78,7 @@ time.sleep(1) p.timeout = True if p.returncode is None: - try: - p.terminate() - except OSError: - pass + terminate(p) threading.Thread(target=t).start() return p @@ -262,10 +259,6 @@ sys.stderr.write( 'warning: --timeout option ignored with --debug\n') options.timeout = 0 - if options.timeout and not hasattr(subprocess.Popen, 'terminate'): - sys.stderr.write('warning: timeout is not supported on this ' - 'platform and will be ignored\n') - options.timeout = 0 if options.py3k_warnings: if sys.version_info[:2] < (2, 6) or sys.version_info[:2] >= (3, 0): parser.error('--py3k-warnings can only be used on Python 2.6+') @@ -343,6 +336,17 @@ else: print "WARNING: Did not find prerequisite tool: "+p +def terminate(proc): + """Terminate subprocess (with fallback for Python versions < 2.6)""" + vlog('# Terminating process %d' % proc.pid) + try: + if hasattr(proc, 'terminate'): + proc.terminate() + else: + os.kill(proc.pid, signal.SIGTERM) + except OSError: + pass + def killdaemons(): # Kill off any leftover daemon processes try: @@ -651,10 +655,7 @@ proc = Popen4(cmd, wd, options.timeout) def cleanup(): - try: - proc.terminate() - except OSError: - pass + terminate(proc) ret = proc.wait() if ret == 0: ret = signal.SIGTERM << 8