Skip to content

Commit

Permalink
Merge pull request #10 from TJM/issue-8
Browse files Browse the repository at this point in the history
Issue #8 - Continue on HTTPException (httplib.BadStatusLine)
  • Loading branch information
Tommy McNeely committed Nov 4, 2014
2 parents d695443 + bd460cb commit b11c9b2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import json
import psutil
import urllib2
import httplib
import ConfigParser
import os
import sys
Expand Down Expand Up @@ -309,18 +310,24 @@ def add_to_newrelic(self):
self.logger.debug('Response: %s' % response.read())

if response.code == 200:
# Only reset on success (allows the exceptions below to continue)
self._successful_run_reset()

response.close()

except httplib.HTTPException, err:
self.logger.error(err)
self.logger.debug("HTTP Exception: %s" % err.read())
pass # continue on this error

except urllib2.HTTPError, err:
self.logger.error(err)
self.logger.debug("ErrorPage: %s" % err.read())
pass #i know, i don't like it either, but we don't want a single failed connection to break the loop.
self.logger.debug("HTTP Error: %s" % err.read())
pass # continue

except urllib2.URLError, err:
# URLError (DNS Error?)
self.logger.error(err)
self.logger.debug('Reason: %s' % err.reason)
pass
self.logger.debug('URL Error: %s' % err.reason)
pass # continue
self._reset_json_data()

0 comments on commit b11c9b2

Please sign in to comment.