Python command line input in a process

别等时光非礼了梦想. 提交于 2019-11-26 21:05:37

When you spawn a thread in Python, it closes stdin. You can't use a subprocess to collect standard input. Use the main thread to collect input instead and post them to the Queue from the main thread. It may be possible to pass the stdin to another thread, but you likely need to close it in your main thread.

AShelly

I was able to work around this by using fdopen() to reopen stdin in the subprocess. See this answer. It seems to be working, I don't know if there are any hidden risks.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!