I wrote a program with web.py, and used the 2>error.txt
to put the errors into a file. This did well on Linux, but on Windows, when an error occurred, nothing was written in the file. 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. 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. So what should I do?
Asked
Active
Viewed 85 times
1

filmor
- 30,840
- 6
- 50
- 48
-
1You might be running into a buffering problem. Try running Python with the `-u` option to disable buffering on `stdin`, `stdout` and `stderr`. This previous question describes a number of possible other solutions if that is the case: http://stackoverflow.com/questions/107705/python-output-buffering – Ross Ridge Aug 14 '14 at 08:00
1 Answers
2
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)).
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.