comparison mxtool/mx.py @ 15823:9acad98567dc

mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350)
author Doug Simon <doug.simon@oracle.com>
date Wed, 21 May 2014 17:57:41 +0200
parents 4900010a15d2
children babe4565c371
comparison
equal deleted inserted replaced
15822:4900010a15d2 15823:9acad98567dc
32 32
33 Full documentation can be found at https://wiki.openjdk.java.net/display/Graal/The+mx+Tool 33 Full documentation can be found at https://wiki.openjdk.java.net/display/Graal/The+mx+Tool
34 """ 34 """
35 35
36 import sys, os, errno, time, subprocess, shlex, types, urllib2, contextlib, StringIO, zipfile, signal, xml.sax.saxutils, tempfile, fnmatch 36 import sys, os, errno, time, subprocess, shlex, types, urllib2, contextlib, StringIO, zipfile, signal, xml.sax.saxutils, tempfile, fnmatch
37 import multiprocessing
37 import textwrap 38 import textwrap
38 import socket 39 import socket
39 import tarfile 40 import tarfile
40 import hashlib 41 import hashlib
41 import xml.parsers.expat 42 import xml.parsers.expat
1842 """ 1843 """
1843 1844
1844 if _opts.killwithsigquit: 1845 if _opts.killwithsigquit:
1845 _send_sigquit() 1846 _send_sigquit()
1846 1847
1848 def is_alive(p):
1849 if isinstance(p, subprocess.Popen):
1850 return p.poll() is not None
1851 assert isinstance(p, multiprocessing.Process), p
1852 return p.is_alive()
1853
1847 for p, args in _currentSubprocesses: 1854 for p, args in _currentSubprocesses:
1848 try: 1855 if is_alive(p):
1849 if get_os() == 'windows': 1856 try:
1850 p.terminate() 1857 if get_os() == 'windows':
1851 else: 1858 p.terminate()
1852 _kill_process_group(p.pid, signal.SIGKILL) 1859 else:
1853 except BaseException as e: 1860 _kill_process_group(p.pid, signal.SIGKILL)
1854 log('error while killing subprocess {} "{}": {}'.format(p.pid, ' '.join(args), e)) 1861 except BaseException as e:
1862 if is_alive(p):
1863 log('error while killing subprocess {} "{}": {}'.format(p.pid, ' '.join(args), e))
1855 1864
1856 if _opts and _opts.verbose: 1865 if _opts and _opts.verbose:
1857 import traceback 1866 import traceback
1858 traceback.print_stack() 1867 traceback.print_stack()
1859 raise SystemExit(codeOrMessage) 1868 raise SystemExit(codeOrMessage)
2293 def sortWorklist(tasks): 2302 def sortWorklist(tasks):
2294 for t in tasks: 2303 for t in tasks:
2295 t._d = None 2304 t._d = None
2296 return sorted(tasks, compareTasks) 2305 return sorted(tasks, compareTasks)
2297 2306
2298 import multiprocessing
2299 cpus = multiprocessing.cpu_count() 2307 cpus = multiprocessing.cpu_count()
2300 worklist = sortWorklist(tasks.values()) 2308 worklist = sortWorklist(tasks.values())
2301 active = [] 2309 active = []
2302 failed = [] 2310 failed = []
2303 while len(worklist) != 0: 2311 while len(worklist) != 0: