def ping_multilaunch(port, stop_event): """ A single manager to ping all launches during multiprocess launches :param port: (int) Listening port number of the DataServer :param stop_event: (Thread.Event) stop event """ ds = DataServer(address=('127.0.0.1', port), authkey=DS_PASSWORD) ds.connect() lp = ds.LaunchPad() while not stop_event.is_set(): for pid, lid in ds.Running_IDs().items(): if lid: try: os.kill(pid, 0) # throws OSError if the process is dead lp.ping_launch(lid) except OSError: pass # means this process is dead! stop_event.wait(PING_TIME_SECS)