changeset 558:14559eb34003

more error catching on celery run_task
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 07 Oct 2010 19:24:03 +0200
parents 29ec9ddbe258
children bc4633a41967
files rhodecode/lib/celerylib/__init__.py
diffstat 1 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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):