Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions raven/transport/threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import logging
import threading
import os
import sys

from time import sleep, time

Expand Down Expand Up @@ -64,18 +65,20 @@ def main_thread_terminated(self):

if not self._timed_queue_join(initial_timeout):
# if that didn't work, wait a bit longer
# NB that size is an approximation, because other threads may
# add or remove items
size = self._queue.qsize()

print("Sentry is attempting to send %i pending error messages"
% size)
print("Waiting up to %s seconds" % timeout)

if os.name == 'nt':
print("Press Ctrl-Break to quit")
else:
print("Press Ctrl-C to quit")

if sys.stdin.isatty() and sys.stdout.isatty():
# NB that size is an approximation, because other threads
# may add or remove items
size = self._queue.qsize()

print("Sentry is attempting to send %i "
"pending error messages" % size)
print("Waiting up to %s seconds" % timeout)

if os.name == 'nt':
print("Press Ctrl-Break to quit")
else:
print("Press Ctrl-C to quit")

self._timed_queue_join(timeout - initial_timeout)

Expand Down