[tor-commits] [doctor/master] Shift bot notification to generate subprocess early too

atagar at torproject.org atagar at torproject.org
Sun Oct 12 22:12:35 UTC 2014


commit 1d33ef1b640b3b0093486ec2b7ec84a30aadde54
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Oct 12 15:10:57 2014 -0700

    Shift bot notification to generate subprocess early too
    
    When I made the prior commit I knew there were a couple other spots we forked,
    but wanted to see if it worked for the main email first. Seems to, so shifting
    the bot notice too to prevent OOMs. The error notification still forks, but
    leaving it as-is for the moment since it seems to be working (that's how I'm
    being notified of OOMs, after all).
---
 consensus_health_checker.py |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/consensus_health_checker.py b/consensus_health_checker.py
index f9dc10e..473a57c 100755
--- a/consensus_health_checker.py
+++ b/consensus_health_checker.py
@@ -203,6 +203,13 @@ def main():
       stderr = subprocess.PIPE,
     )
 
+    bot_notice_process = subprocess.Popen(
+      ['mail', '-E', '-s', 'Announce or', 'tor-misc at commit.noreply.org'],
+      stdin = subprocess.PIPE,
+      stdout = subprocess.PIPE,
+      stderr = subprocess.PIPE,
+    )
+
   # loads configuration data
 
   config = stem.util.conf.get_config("consensus_health")
@@ -244,7 +251,11 @@ def main():
 
       # notification for #tor-bots
 
-      util.send('Announce or', body_text = '\n'.join(['[consensus-health] %s' % issue for issue in issues]), destination = 'tor-misc at commit.noreply.org')
+      stdout, stderr = bot_notice_process.communicate('\n'.join(['[consensus-health] %s' % issue for issue in issues]))
+      exit_code = mail_process.poll()
+
+      if exit_code != 0:
+        raise ValueError("Unable to send email: %s" % stderr.strip())
   else:
     if issues:
       log.info("All %i issues were suppressed. Not sending a notification." % len(issues))



More information about the tor-commits mailing list