import threading


def startWithCallback(process, onExit):
    """
    Call process.start(), and then calls the function onExit when the
    subprocess completes.

    onExit is a callable object, will receive process as parameter.
    """
    def runInThread(process, onExit):
        process.join()
        onExit(process)
        return

    thread = threading.Thread(target=runInThread,
                              args=(process, onExit))
    
    process.start()
    thread.start()

    return thread