Make socket timeout configurable.
authorAdam Sampson <ats@offog.org>
Sat, 20 Sep 2003 18:14:45 +0000 (18:14 +0000)
committerAdam Sampson <ats@offog.org>
Sat, 20 Sep 2003 18:14:45 +0000 (18:14 +0000)
NEWS
config
rawdoglib/rawdog.py

diff --git a/NEWS b/NEWS
index 13215f472bee91df5513e49b44b12b2a50496b49..4fbd30c071815e5c9a8c97410d76e2da73e2e8c7 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,9 @@ write").  The old syntax will be supported until 2.0.
 
 Warning output from --update now goes to stderr instead of stdout.
 
+Made the socket timeout configurable (which also means the included copy
+of feedparser isn't modified any more).
+
 - rawdog 1.2
 
 Updated feedparser to 2.5.2, which fixes a bug that was making rawdog
diff --git a/config b/config
index b39306f291c94b8d9377bcc6b40bcd0705fe415f..c4e643fe2b876388813ccd29afb64cdff7173f2b 100644 (file)
--- a/config
+++ b/config
@@ -25,6 +25,11 @@ userefresh 1
 # Whether to show the list of active feeds in the generated HTML.
 showfeeds 1
 
+# The time in seconds that rawdog will wait before considering a feed
+# unreachable when trying to connect. If you're getting lots of timeout
+# errors and are on a slow connection, increase this.
+timeout 30
+
 # The feeds you want to watch, in the format "feed period url".
 # The period is the minimum time in minutes between updates; if less
 # than period minutes have passed, "rawdog update" will skip that feed.
index c5b7e45cafcd01c7338676eb1015f5b393955d16..9982fbb570009c65f05c73859b8d71ff318dd61b 100644 (file)
@@ -23,9 +23,6 @@ import os, time, sha, getopt, sys
 from StringIO import StringIO
 import timeoutsocket
 
-# Override the timeout set by feedparser.
-timeoutsocket.setDefaultSocketTimeout(30)
-
 def format_time(secs, config):
        """Format a time and date nicely."""
        t = time.localtime(secs)
@@ -254,6 +251,7 @@ class Config:
                        "timeformat" : "%I:%M %p",
                        "userefresh" : 0,
                        "showfeeds" : 1,
+                       "timeout" : 30,
                        }
 
        def __getitem__(self, key): return self.config[key]
@@ -297,6 +295,8 @@ class Config:
                        self["userefresh"] = int(l[1])
                elif l[0] == "showfeeds":
                        self["showfeeds"] = int(l[1])
+               elif l[0] == "timeout":
+                       self["timeout"] = int(l[1])
                else:
                        raise ConfigError("Unknown config command: " + l[0])
 
@@ -317,6 +317,8 @@ class Rawdog(Persistable):
        def update(self, config, feedurl = None):
                now = time.time()
 
+               timeoutsocket.setDefaultSocketTimeout(config["timeout"])
+
                seenfeeds = {}
                for (url, period) in config["feedslist"]:
                        seenfeeds[url] = 1