From 7040010cdcffe92b3929e9ea8faa4e8c7410cf31 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 13 Feb 2014 21:27:58 +0530 Subject: [PATCH] Plugin mirror script: Add a timeout so that the script does not hang if the network or the source server goes down --- setup/plugins_mirror.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup/plugins_mirror.py b/setup/plugins_mirror.py index bead10567c..edf18b90f6 100644 --- a/setup/plugins_mirror.py +++ b/setup/plugins_mirror.py @@ -6,7 +6,7 @@ from __future__ import (unicode_literals, division, absolute_import, __license__ = 'GPL v3' __copyright__ = '2013, Kovid Goyal ' -import urllib2, re, HTMLParser, zlib, gzip, io, sys, bz2, json, errno, urlparse, os, zipfile, ast, tempfile, glob, fcntl, atexit, stat +import urllib2, re, HTMLParser, zlib, gzip, io, sys, bz2, json, errno, urlparse, os, zipfile, ast, tempfile, glob, fcntl, atexit, stat, socket from future_builtins import map, zip, filter from collections import namedtuple from multiprocessing.pool import ThreadPool @@ -26,6 +26,8 @@ INDEX = MR_URL + 'showpost.php?p=1362767&postcount=1' IndexEntry = namedtuple('IndexEntry', 'name url donate history uninstall deprecated thread_id') u = HTMLParser.HTMLParser().unescape +socket.setdefaulttimeout(60) + def read(url, get_info=False): # {{{ if url.startswith("file://"): return urllib2.urlopen(url).read()