comparison tests/run-tests.py @ 14971:0b21ae0a2366

tests: use getattr instead of hasattr
author Augie Fackler <durin42@gmail.com>
date Mon, 25 Jul 2011 16:37:18 -0500
parents b601b9eb372d
children 4fae5df4b1bb
comparison
equal deleted inserted replaced
14970:592e45b7d43e 14971:0b21ae0a2366
338 338
339 def terminate(proc): 339 def terminate(proc):
340 """Terminate subprocess (with fallback for Python versions < 2.6)""" 340 """Terminate subprocess (with fallback for Python versions < 2.6)"""
341 vlog('# Terminating process %d' % proc.pid) 341 vlog('# Terminating process %d' % proc.pid)
342 try: 342 try:
343 if hasattr(proc, 'terminate'): 343 getattr(proc, 'terminate', lambda : os.kill(proc.pid, signal.SIGTERM))()
344 proc.terminate()
345 else:
346 os.kill(proc.pid, signal.SIGTERM)
347 except OSError: 344 except OSError:
348 pass 345 pass
349 346
350 def killdaemons(): 347 def killdaemons():
351 # Kill off any leftover daemon processes 348 # Kill off any leftover daemon processes