简体   繁体   English

在程序完成之前,cmd.exe不会重定向错误

[英]cmd.exe does not redirect errors until the program is finished

I wrote a program with web.py, and used the 2>error.txt to put the errors into a file. 我用web.py编写了一个程序,并使用2>error.txt将错误放入文件中。 This did well on Linux, but on Windows, when an error occurred, nothing was written in the file. 这在Linux上效果很好,但是在Windows上,当发生错误时,文件中未写入任何内容。 I found that on Windows, at normal time, an error occurred, the program which raise the error will be shut down, and the error will be put into the file. 我发现在Windows上,正常情况下会发生错误,引发该错误的程序将被关闭,并且该错误将被放入文件中。 But the thing is that in web.py, an error occurred, the program won't be shutdown, so the error won't be written into the file. 但问题是在web.py中,发生了错误,程序不会关闭,因此不会将错误写入文件中。 So what should I do? 所以我该怎么做?

In this mailing list entry it is stated that 此邮件列表条目中指出:

On Windows, stdout and stderr are unbuffered if they refer to a character device, fully buffered otherwise (Windows doesn't have line buffering; setvbuf(_IOLBF) is equivalent to setvbuf(_IOFBF)). 在Windows上,如果stdout和stderr引用字符设备,则将不对其进行缓冲,否则将完全缓冲(Windows没有行缓冲; setvbuf(_IOLBF)等同于setvbuf(_IOFBF))。

I'll try to find an additional source for this but this does indeed explain your problem. 我将尝试为此找到其他来源,但这确实可以解释您的问题。 You can check here: 您可以在这里查看:

Disable output buffering 禁用输出缓冲

how to shut off output buffering in Python. 如何在Python中关闭输出缓冲。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CMD.exe如何识别扩展需要程序? - How CMD.exe recognize an extension need program? Python 未安装且终端 shell 路径“cmd.exe”不存在 - Python is not installed and The terminal shell path “cmd.exe” does not exist 保持cmd.exe打开 - Keep cmd.exe open 用子进程包装cmd.exe - wrapping cmd.exe with subprocess Python - Stray cmd.exe窗口导致程序挂起。 我如何关闭这个迷路程序? - Python - Stray cmd.exe window causes program to hang. How can I close this stray program? 在Windows shell脚本(cmd.exe)中,如何将程序的标准输出分配给环境变量? - In Windows shell scripting (cmd.exe) how do you assign the stdout of a program to an environment variable? 从python执行程序,以便在单独的cmd.exe窗口中打开 - Executing a program from python so that it opens in separate cmd.exe window 从命令行运行程序,提示输入密码并自动为其提供密码(cmd.exe,python) - Run program from command line what prompts password and automatically provide password for it (cmd.exe, python) 我的程序在Python shell中运行,但在cmd.exe中运行时无法识别我的输入 - My program works in Python shell but doesn't recognize my input when it runs in cmd.exe Python IDLE脚本不显示子进程的输出,但cmd.exe可以 - Python IDLE script does not show output of subprocess but cmd.exe does
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM