diff options
Diffstat (limited to 'check.py')
-rw-r--r-- | check.py | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -1,6 +1,7 @@ #!/usr/bin/python import logging +import socket import urllib2 import time import rfc822 @@ -12,13 +13,17 @@ import urlparse class GardCheck: # Base class which provides some helper functions - def __init__(self, url, log=True): + def __init__(self, url, log=True, timeout=30): self.url = url if log: self.logger = logging.getLogger('') else: self.logger = None + # By default urllib2 has no timeout, so we need to set a sane + # global maximum + socket.setdefaulttimeout(timeout) + def log_info(self, msg): if self.logger is not None: self.logger.info(msg) |