diff --git a/luigi/worker.py b/luigi/worker.py
index <HASH>..<HASH> 100644
--- a/luigi/worker.py
+++ b/luigi/worker.py
@@ -144,7 +144,7 @@ class Worker(object):
                     raise  # TODO: not necessarily true that we want to break on the first exception
                 status = 'FAILED'
                 expl = traceback.format_exc(sys.exc_info()[2])
-                if self.__erroremail: #TODO: check if running in background mode
+                if self.__erroremail and not sys.stdout.isatty():
                     logging.error("Error while running %s. Sending error email", task)
                     send_email("Luigi: %s FAILED" % task, expl,
                                (self.__erroremail,))
Fix AI-<I>, by checking whether stdout is a tty.

Change-Id: I9a<I>a6bf<I>f<I>fde6ccc6c6f7a<I>c3b<I>
Reviewed-on: <URL>