store timeout in configuration

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3183 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2006-05-15 18:05:17 +00:00
parent c8bcdf7d79
commit 938d193446
2 changed files with 6 additions and 7 deletions

View file

@ -145,6 +145,8 @@ class Configuration (dict):
self["warnsizebytes"] = None
self["nntpserver"] = os.environ.get("NNTP_SERVER", None)
self["threads"] = 10
# socket timeout in seconds
self["timeout"] = 60
def init_logging (self, debug=None):
"""

View file

@ -27,10 +27,6 @@ import pprint
import socket
import optparse
# set default 60 seconds socket timeout before importing anything else
default_timeout = 60
socket.setdefaulttimeout(default_timeout)
import linkcheck
# override optparse gettext method with the one from linkcheck.init_i18n()
optparse._ = _
@ -592,7 +588,7 @@ if options.pause is not None:
config["wait"] = options.pause
else:
print_usage(_("Illegal argument %r for option %s") % \
(options.pause, "'-P, --pause'"))
(options.pause, "'-P, --pause'"))
if options.profile is not None:
do_profile = options.profile
if options.quiet is not None:
@ -607,10 +603,11 @@ if options.threads is not None:
config["threads"] = options.threads
if options.timeout is not None:
if options.timeout > 0:
socket.setdefaulttimeout(options.timeout)
config["timeout"] = options.timeout
else:
print_usage(_("Illegal argument %r for option %s") % \
(options.timeout, "'--timeout'"))
(options.timeout, "'--timeout'"))
socket.setdefaulttimeout(config["timeout"])
if options.username is not None:
_username = options.username
constructauth = True