Author: poeml Date: Tue Sep 1 18:19:49 2009 New Revision: 7783 URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=7783&view=rev Log: mirrorprobe: - clean up error handling a bit - handle more errors (e.g. socket timeouts during response reading) and log them properly - for exceptions yet unhandled, print info about the mirror that caused them Modified: trunk/mirrorprobe/mirrorprobe.py Modified: trunk/mirrorprobe/mirrorprobe.py URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mirrorprobe/mirrorprobe.py?rev=7783&r1=7782&r2=7783&view=diff ============================================================================== --- trunk/mirrorprobe/mirrorprobe.py (original) +++ trunk/mirrorprobe/mirrorprobe.py Tue Sep 1 18:19:49 2009 @@ -59,6 +59,7 @@ try: response = urllib2.urlopen(req) + try: mirror.response_code = response.code # if the web server redirects to an ftp:// URL, our response won't have a code attribute @@ -68,17 +69,24 @@ # count as success mirror.response_code = 200 logging.debug('mirror %s redirects to ftp:// URL' % mirror.identifier) + logging.debug('%s got response for %s: %s' % (threading.currentThread().getName(), mirror.identifier, getattr(response, 'code', None))) - try: - mirror.response = response.read() - except ValueError, e: - if str(e).startswith('invalid literal for int()'): - mirror.response = 'response not read due to http://bugs.python.org/issue1205' - logging.info('mirror %s sends broken chunked reply, see http://bugs.python.org/issue1205' % mirror.identifier) - else: - raise + mirror.response = response.read() mirror.status_baseurl_new = True + + + except ValueError, e: + if str(e).startswith('invalid literal for int()'): + mirror.response = 'response not read due to http://bugs.python.org/issue1205' + logging.info('mirror %s sends broken chunked reply, see http://bugs.python.org/issue1205' % mirror.identifier) + + except socket.timeout, e: + mirror.response = 'socket timeout in reading response: %s' % e + + except socket.error, e: + #errno, errstr = sys.exc_info()[:2] + mirror.response = "socket error: %s" % e except httplib.BadStatusLine: mirror.response_code = None @@ -94,14 +102,16 @@ except IOError, e: # IOError: [Errno ftp error] (111, 'Connection refused') - print e.errno if e.errno == 'ftp error': mirror.response_code = 0 - mirror.response = "%s" % e.errno - #logging.info('mirror %s gives an "ftp error"' % mirror.identifier) + mirror.response = "%s: %s" % (e.errno, e.strerror) else: + print mirror.identifier, mirror.baseurl, 'errno:', e.errno raise + except: + print mirror.identifier, mirror.baseurl + raise # not reached, if the timeout goes off mirror.timed_out = False _______________________________________________ mirrorbrain-commits mailing list Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/ Note: To remove yourself from this list, send a mail with the content unsubscribe to the address mirrorbrain-commits-request_at_mirrorbrain.orgReceived on Tue Sep 01 2009 - 16:19:51 GMT
This archive was generated by hypermail 2.2.0 : Tue Sep 01 2009 - 16:45:07 GMT