Bug 1388694 - Add a delay between OF Robot comments, to avoid overwhelming bugzilla; r=emorley
authorGeoff Brown <gbrown@mozilla.com>
Wed, 09 Aug 2017 12:36:27 -0600
changeset 337 18613447b7e10102cd0556ee5497447c829b8fb3
parent 336 ba322694a641041ef23aef8dbd3dc030499dca75
child 338 f7cca9ada0e0a3d402f4517668b88fdd5cfc247f
push id285
push usergbrown@mozilla.com
push dateWed, 09 Aug 2017 18:36:55 +0000
reviewersemorley
bugs1388694
Bug 1388694 - Add a delay between OF Robot comments, to avoid overwhelming bugzilla; r=emorley
woo_commenter.py
--- a/woo_commenter.py
+++ b/woo_commenter.py
@@ -4,16 +4,17 @@
 # version 2.0 (the "License"). You can obtain a copy of the License at
 # http://mozilla.org/MPL/2.0/.
 
 import ConfigParser
 import datetime
 import os
 import re
 import sys
+import time
 from operator import itemgetter
 from optparse import OptionParser
 
 import requests
 import tempita
 from requests.exceptions import ConnectionError, HTTPError, Timeout
 
 from woo_client import TopBugs
@@ -79,16 +80,19 @@ def get_triage_info_for_bug(bmo_session,
     except HTTPError:
         print "HTTPError %s: %s" % (r.status_code, r.text)
     return info
 
 
 def main():
     """Posts a bug comment containing stats to each bug whose total number of
        occurrences (in the chosen time window) met the appropriate threshold."""
+
+    print "woo_commenter start at %s" % datetime.datetime.now()
+
     parser = OptionParser()
     parser.add_option('--weekly', action='store_true', dest='weekly_mode', default=False,
                       help='generate weekly summaries instead of the default daily summaries')
     parser.add_option('--test', action='store_true', dest='test_mode', default=False,
                       help='output bug comments to stdout rather than submitting to Bugzilla')
     options, _ = parser.parse_args()
 
     try:
@@ -189,14 +193,16 @@ def main():
                     whiteboard = re.sub("\[stockwell.*?\]", "", whiteboard)
                     whiteboard = whiteboard + "[stockwell needswork:DOM]"
                     params['whiteboard'] = whiteboard
         if options.test_mode:
             print "\n# Bug %s: update with %s" % (bug_id, params)
         else:
             print "Submitting comment to bug %s (%d occurrences)" % (bug_id, counts['total'])
             submit_bug_change(bmo_session, bug_id, params)
+            # sleep between comment submissions to avoid overwhelming servers
+            time.sleep(1)
 
-    print "Complete!"
+    print "woo_commenter complete at %s" % datetime.datetime.now()
 
 
 if __name__ == '__main__':
     main()