tests/killdaemons.py
author Pierre-Yves David <pierre-yves.david@fb.com>
Fri, 28 Feb 2014 00:40:29 -0800
changeset 821 202376586cf6
parent 7 cc592295900f
child 1222 88e61e45026d
permissions -rwxr-xr-x
exchange: introduce a wireprotocol command to push markers Pushkey is not adapted to transmit a stream of binary data. We used it as a hack so far. We add a new wire protocol command to speed the things up (and also push all the markers in a single transaction). The proper way to do it is to introduce bundle2 in core, but this will already help in the mean time.

#!/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