diff --git a/linkcheck/configuration/__init__.py b/linkcheck/configuration/__init__.py index 9cd14b0a..5cf327ee 100644 --- a/linkcheck/configuration/__init__.py +++ b/linkcheck/configuration/__init__.py @@ -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): """ diff --git a/linkchecker b/linkchecker index 20ea0c11..defe4a7e 100755 --- a/linkchecker +++ b/linkchecker @@ -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