# HG changeset patch # User Marcin Kuzminski # Date 1286472243 -7200 # Node ID 14559eb34003b3a46cdcc523f24208e37ffa79ab # Parent 29ec9ddbe2589930feba673106b8fcccc04bbd41 more error catching on celery run_task diff -r 29ec9ddbe258 -r 14559eb34003 rhodecode/lib/celerylib/__init__.py --- a/rhodecode/lib/celerylib/__init__.py Thu Oct 07 18:30:50 2010 +0200 +++ b/rhodecode/lib/celerylib/__init__.py Thu Oct 07 19:24:03 2010 +0200 @@ -6,6 +6,7 @@ import sys import traceback from hashlib import md5 +import socket log = logging.getLogger(__name__) class ResultWrapper(object): @@ -21,14 +22,17 @@ t = task.delay(*args, **kwargs) log.info('running task %s', t.task_id) return t + except socket.error, e: + if e.errno == 111: + log.debug('Unable to connect to celeryd. Sync execution') + else: + log.error(traceback.format_exc()) + except KeyError, e: + log.debug('Unable to connect to celeryd. Sync execution') except Exception, e: - print e - if e.errno == 111: - log.debug('Unnable to connect. Sync execution') - else: - log.error(traceback.format_exc()) - #pure sync version - return ResultWrapper(task(*args, **kwargs)) + log.error(traceback.format_exc()) + + return ResultWrapper(task(*args, **kwargs)) def locked_task(func):