stop_event = threading.Event()
process = subprocess.Popen(command, cwd=workingdir, env=env, shell=useshell,
    stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stderr_thread = threading.Thread(target=simple_io_thread, args=(process.
    stderr, outputqueue, 'STDERR', stop_event))
stdout_thread = threading.Thread(target=simple_io_thread, args=(process.
    stdout, outputqueue, 'STDOUT', stop_event))
stderr_thread.daemon = True
stdout_thread.daemon = True
stderr_thread.start()
stdout_thread.start()
Asynchronous subprocess on Windows