From e2612ab3f6963df37f9ca2542718c5712966ca29 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 11 Oct 2010 20:49:04 -0500 Subject: mirrorcheck: catch and handle another socket timeout case We were seeing processes hang on the Arch server. It looks like there are ways for socket.timeout to come out of the main check code, so add another except block to catch this case. In addition, make sure we always call task_done() even on failures so processes eventually die. Signed-off-by: Dan McGee --- mirrors/management/commands/mirrorcheck.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'mirrors') diff --git a/mirrors/management/commands/mirrorcheck.py b/mirrors/management/commands/mirrorcheck.py index 210505fa..4f677a20 100644 --- a/mirrors/management/commands/mirrorcheck.py +++ b/mirrors/management/commands/mirrorcheck.py @@ -56,7 +56,8 @@ class Command(NoArgsCommand): def parse_rfc3339_datetime(time): # '2010-09-02 11:05:06+02:00' - m = re.match('^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})([-+])(\d{2}):(\d{2})', time) + m = re.match('^(\d{4})-(\d{2})-(\d{2}) ' + '(\d{2}):(\d{2}):(\d{2})([-+])(\d{2}):(\d{2})', time) if m: vals = m.groups() parsed = datetime(int(vals[0]), int(vals[1]), int(vals[2]), @@ -120,6 +121,10 @@ def check_mirror_url(mirror_url): elif isinstance(e.reason, socket.error): log.error = e.reason.args[1] logger.debug("failed: %s, %s" % (url, log.error)) + except socket.timeout, e: + log.is_success = false + log.error = "Connection timed out." + logger.debug("failed: %s, %s" % (url, log.error)) log.save() return log @@ -128,8 +133,10 @@ def mirror_url_worker(queue): while True: try: item = queue.get(block=False) - check_mirror_url(item) - queue.task_done() + try: + check_mirror_url(item) + finally: + queue.task_done() except Empty: return 0 -- cgit v1.2.3-2-g168b