summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'check.py')
-rw-r--r--check.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/check.py b/check.py
index fba550b..0f6aebb 100644
--- a/check.py
+++ b/check.py
@@ -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)