From 898eec10ac585e9afd2fba4d2bfe2fb6c6eb6134 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Fri, 12 Nov 2010 06:39:33 +0100 Subject: [PATCH] [entropy.client.services.ugc] make set_gzip_compression more fault tolerant in regards to socket errors --- .../entropy/client/services/ugc/commands.py | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/libraries/entropy/client/services/ugc/commands.py b/libraries/entropy/client/services/ugc/commands.py index 2c858cea5..a8b8b26dd 100644 --- a/libraries/entropy/client/services/ugc/commands.py +++ b/libraries/entropy/client/services/ugc/commands.py @@ -254,11 +254,21 @@ class Base: const_convert_to_rawstring('compression'), const_convert_to_rawstring(do), ) - self.Service.transmit(cmd) - data = self.Service.receive() - if data == self.Service.answers['ok']: - return True - return False + fail_count = 5 + while True: + try: + self.Service.transmit(cmd) + data = self.Service.receive() + except (self.socket.error, self.struct.error, SSLError) as err: + const_debug_write(__name__, + darkred("set_gzip_compression: error: " + repr(err))) + fail_count -= 1 + if fail_count == 0: + raise + continue + if data == self.Service.answers['ok']: + return True + return False def service_login(self, username, password, session_id):