[英]Prevent python multiprocess Process from accessing stdout
I have a script that is calling an external library in a child process, this external library is printing status updates in the from of sys.stdout.write calls. 我有一个在子进程中调用外部库的脚本,该外部库正在从sys.stdout.write调用中打印状态更新。
Its interface has no option for suppressing them, is there any way to redirect a child process' stdout to hide it? 它的界面没有抑制它们的选项,是否有任何方法可以重定向子进程的标准输出以将其隐藏?
The program is using multiprocessing.Process the code snippet would be slightly unweildy as the call to stdout.write happens a few classes deep inside a generator. 该程序正在使用多处理。处理代码片段会有点不舒服,因为对stdout.write的调用发生在生成器内部的几个类上。
发送到/ dev / null:
sys.stdout = open(os.devnull)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.