testing/xvfb.py
def kill(proc, name, timeout_in_seconds=10):
  """Tries to kill |proc| gracefully with a timeout for each signal."""
  if not proc:
    return

  proc.terminate()
  thread = threading.Thread(target=proc.wait)
  thread.start()

  thread.join(timeout_in_seconds)
  if thread.is_alive():
    print('%s running after SIGTERM, trying SIGKILL.\n' % name, file=sys.stderr)
    proc.kill()

  thread.join(timeout_in_seconds)
  if thread.is_alive():
    print('%s running after SIGTERM and SIGKILL; good luck!\n' % name,
          file=sys.stderr)
Tries to kill |proc| gracefully with a timeout for each signal.
Tries to kill |proc| gracefully with a timeout for each signal.
Tries to kill |proc| gracefully with a timeout for each signal .
def kill(proc, name, timeout_in_seconds=10):
  if not proc:
    return
  proc.terminate()
  thread = threading.Thread(target=proc.wait)
  thread.start()
  thread.join(timeout_in_seconds)
  if thread.is_alive():
    print('%s running after SIGTERM, trying SIGKILL.\n' % name, file=sys.stderr)
    proc.kill()
  thread.join(timeout_in_seconds)
  if thread.is_alive():
    print('%s running after SIGTERM and SIGKILL; good luck!\n' % name,
          file=sys.stderr)
def kill ( proc , name , timeout_in_seconds = 10 ) : if not proc : return proc . terminate ( ) thread = threading . Thread ( target = proc . wait ) thread . start ( ) thread . join ( timeout_in_seconds ) if thread . is_alive ( ) : print ( '%s running after SIGTERM, trying SIGKILL.\n' % name , file = sys . stderr ) proc . kill ( ) thread . join ( timeout_in_seconds ) if thread . is_alive ( ) : print ( '%s running after SIGTERM and SIGKILL; good luck!\n' % name , file = sys . stderr )
Tries to kill |proc| gracefully with a timeout for each signal.
Tries to kill |proc| gracefully with a timeout for each signal .
"""Tries to kill |proc| gracefully with a timeout for each signal."""
proc
name
timeout_in_seconds