From 978d4e3f231b60394bde2233f6e8417df35c55f8 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sat, 20 Sep 2003 18:14:45 +0000 Subject: [PATCH] Make socket timeout configurable. --- NEWS | 3 +++ config | 5 +++++ rawdoglib/rawdog.py | 8 +++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 13215f4..4fbd30c 100644 --- 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 b39306f..c4e643f 100644 --- 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. diff --git a/rawdoglib/rawdog.py b/rawdoglib/rawdog.py index c5b7e45..9982fbb 100644 --- a/rawdoglib/rawdog.py +++ b/rawdoglib/rawdog.py @@ -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 -- 2.35.1