tests/killdaemons.py
author Pierre-Yves David <pierre-yves.david@fb.com>
Tue, 20 May 2014 22:36:47 -0700
changeset 962 d04a52f40f41
parent 7 cc592295900f
child 1222 88e61e45026d
permissions -rwxr-xr-x
evolve: install progress support for the bundle2 pull path The custom wireprotocol command had a trick to display progress while pulling. We reinstall such logic for the new path using bundle2. Its notable that we are using the bundle2 advisory parameter for this purpose.

#!/usr/bin/env python

import os, time, errno, signal

# Kill off any leftover daemon processes
try:
    fp = open(os.environ['DAEMON_PIDS'])
    for line in fp:
        try:
            pid = int(line)
        except ValueError:
            continue
        try:
            os.kill(pid, 0)
            os.kill(pid, signal.SIGTERM)
            for i in range(10):
                time.sleep(0.05)
                os.kill(pid, 0)
            os.kill(pid, signal.SIGKILL)
        except OSError, err:
            if err.errno != errno.ESRCH:
                raise
    fp.close()
except IOError:
    pass