raven-python
raven-python copied to clipboard
Only print to stdout if stdout is connected to a tty(-like) device
We are running the raven python client inside of a (yes, very old school, I agree) CGI web application and would like to use a threaded transport, so that normal operation can continue while raven is working.
However, in rare but not rare enough cases, the CGI process is about to terminate before raven has sent all messages, and then, some output "Sentry is attempting to send... Hit Ctrl+C to abort" appears on stdout, which - lame old CGI - is the web page sent to the client. In worst case, the output is seen as (broken) HTTP headers, leading to interesting HTTP status codes from the web server.
To avoid the stdout output, as discussed in https://github.com/getsentry/raven-python/pull/932, I just added an isatty() check.
So: The overall diff is very small in fact, it's just that I had to change a bit of indent.
How do you think about that "if sys.stdin.isatty() and sys.stdout.isatty()" in my last commit?
Would be great to see this merged anytime soon.
Hi all,
We have similar issue, but i think it would be better to print these messages to STDERR instead of STDOUT.