[英]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:
您可以在这里查看:
how to shut off output buffering in Python. 如何在Python中关闭输出缓冲。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.