raven-python icon indicating copy to clipboard operation
raven-python copied to clipboard

Only print to stdout if stdout is connected to a tty(-like) device

Open frietsch-ot opened this issue 8 years ago • 3 comments

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.

frietsch-ot avatar Jan 17 '17 11:01 frietsch-ot

How do you think about that "if sys.stdin.isatty() and sys.stdout.isatty()" in my last commit?

frietsch-ot avatar Jan 24 '17 08:01 frietsch-ot

Would be great to see this merged anytime soon.

Maelcom avatar Mar 19 '17 13:03 Maelcom

Hi all,

We have similar issue, but i think it would be better to print these messages to STDERR instead of STDOUT.

katyukha avatar Feb 27 '20 09:02 katyukha