comparison mxtool/mx.py @ 15786:d54cca247d0b

mx: propagate failure from forked Java compilation task back up to parent (GRAAL-350)
author Doug Simon <doug.simon@oracle.com>
date Tue, 20 May 2014 15:35:35 +0200
parents 7a6f6a7ef886
children 718034423138
comparison
equal deleted inserted replaced
15785:7a6f6a7ef886 15786:d54cca247d0b
2246 2246
2247 def joinTasks(tasks): 2247 def joinTasks(tasks):
2248 failed = [] 2248 failed = []
2249 for t in tasks: 2249 for t in tasks:
2250 t.proc.join() 2250 t.proc.join()
2251 _removeSubprocess(t.sub)
2251 if t.proc.exitcode != 0: 2252 if t.proc.exitcode != 0:
2252 failed.append(t) 2253 failed.append(t)
2253 return failed 2254 return failed
2254 2255
2255 def checkTasks(tasks): 2256 def checkTasks(tasks):
2256 active = [] 2257 active = []
2257 for t in tasks: 2258 for t in tasks:
2258 if t.proc.is_alive(): 2259 if t.proc.is_alive():
2259 active.append(t) 2260 active.append(t)
2260 else: 2261 else:
2261 _removeSubprocess(t.sub)
2262 if t.proc.exitcode != 0: 2262 if t.proc.exitcode != 0:
2263 return ([], joinTasks(tasks)) 2263 return ([], joinTasks(tasks))
2264 return (active, []) 2264 return (active, [])
2265 2265
2266 def remainingDepsDepth(task): 2266 def remainingDepsDepth(task):
2287 2287
2288 import multiprocessing 2288 import multiprocessing
2289 cpus = multiprocessing.cpu_count() 2289 cpus = multiprocessing.cpu_count()
2290 worklist = sortWorklist(tasks.values()) 2290 worklist = sortWorklist(tasks.values())
2291 active = [] 2291 active = []
2292 failed = []
2292 while len(worklist) != 0: 2293 while len(worklist) != 0:
2293 while True: 2294 while True:
2294 active, failed = checkTasks(active) 2295 active, failed = checkTasks(active)
2295 if len(failed) != 0: 2296 if len(failed) != 0:
2296 assert not active, active 2297 assert not active, active
2299 # Sleep for 1 second 2300 # Sleep for 1 second
2300 time.sleep(1) 2301 time.sleep(1)
2301 else: 2302 else:
2302 break 2303 break
2303 2304
2305 if len(failed) != 0:
2306 break
2307
2304 def executeTask(task): 2308 def executeTask(task):
2305 # Clear sub-process list cloned from parent process 2309 # Clear sub-process list cloned from parent process
2306 del _currentSubprocesses[:] 2310 del _currentSubprocesses[:]
2307 task.execute() 2311 task.execute()
2308 2312
2321 task.sub = _addSubprocess(task.proc, ['JavaCompileTask', str(task)]) 2325 task.sub = _addSubprocess(task.proc, ['JavaCompileTask', str(task)])
2322 if len(active) == cpus: 2326 if len(active) == cpus:
2323 break 2327 break
2324 2328
2325 worklist = sortWorklist(worklist) 2329 worklist = sortWorklist(worklist)
2326 joinTasks(active) 2330
2331 failed += joinTasks(active)
2332 if len(failed):
2333 for t in failed:
2334 log('Compiling {} failed'.format(t.proj.name))
2335 abort('{} Java compilation tasks failed'.format(len(failed)))
2327 2336
2328 for dist in _dists.values(): 2337 for dist in _dists.values():
2329 archive(['@' + dist.name]) 2338 archive(['@' + dist.name])
2330 2339
2331 if suppliedParser: 2340 if suppliedParser: