added wait time and brought exit back in

Yeah, probably not a good idea to have a potential inf loop, limiting it to 10 attempts with 5 sec wait time
This commit is contained in:
John Leonardo 2016-08-14 00:33:34 -07:00 committed by GitHub
parent 8102f2020b
commit 526d13d6c1
1 changed files with 8 additions and 1 deletions

View File

@ -3,6 +3,7 @@
# Reads in STDIN. If the stream is not empty, mail it to the system administrator. # Reads in STDIN. If the stream is not empty, mail it to the system administrator.
import sys import sys
import time
import smtplib import smtplib
from email.message import Message from email.message import Message
@ -21,9 +22,15 @@ admin_addr = "administrator@" + env['PRIMARY_HOSTNAME']
# Read in STDIN. # Read in STDIN.
content = sys.stdin.read().strip() content = sys.stdin.read().strip()
# If there's nothing coming in, just exit. # Checks if content is nil. If nil, it tries again, with 5 second wait time. after 10 attempts, quits
i = 0
while content == "": while content == "":
content = sys.stdin.read().strip() content = sys.stdin.read().strip()
time.sleep(5)
i = i + 1
if i == 10:
sys.exit(0)
# create MIME message # create MIME message
msg = Message() msg = Message()