From 6553cd398f6068e79da13a19ffb001bf1c40a5ec Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sun, 16 Dec 2012 20:04:22 +0100 Subject: [PATCH] [entropy.fetchers] catch socket.error exception (can be raised with "Connection reset by peer") --- lib/entropy/fetchers.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/entropy/fetchers.py b/lib/entropy/fetchers.py index f5b480f85..a024e1f81 100644 --- a/lib/entropy/fetchers.py +++ b/lib/entropy/fetchers.py @@ -584,6 +584,12 @@ class UrlFetcher(TextInterface): self.__status = UrlFetcher.TIMEOUT_FETCH_ERROR do_return = True + except socket.error: + # connection reset by peer? + self.__urllib_close(True) + self.__status = UrlFetcher.GENERIC_FETCH_ERROR + do_return = True + except ValueError: # malformed, unsupported URL? raised by urllib self.__urllib_close(True) self.__status = UrlFetcher.GENERIC_FETCH_ERROR @@ -683,14 +689,23 @@ class UrlFetcher(TextInterface): self.__abort_check_func() if self.__thread_stop_func != None: self.__thread_stop_func() + except KeyboardInterrupt: self.__urllib_close(False) raise + except socket.timeout: self.__urllib_close(False) self.__status = UrlFetcher.TIMEOUT_FETCH_ERROR return self.__status - except: + + except socket.error: + # connection reset by peer? + self.__urllib_close(False) + self.__status = UrlFetcher.GENERIC_FETCH_ERROR + return self.__status + + except Exception: # python 2.4 timeouts go here self.__urllib_close(True) self.__status = UrlFetcher.GENERIC_FETCH_ERROR