Browse Source

Merge branch 'mattlong/unpickleable_args_fix'

Ask Solem 12 years ago
parent
commit
384c54c05a
1 changed files with 9 additions and 2 deletions
  1. 9 2
      celery/utils/serialization.py

+ 9 - 2
celery/utils/serialization.py

@@ -129,11 +129,18 @@ class UnpickleableExceptionWrapper(Exception):
     exc_args = None
 
     def __init__(self, exc_module, exc_cls_name, exc_args, text=None):
+        safe_exc_args = []
+        for arg in exc_args:
+            try:
+                pickle.dumps(deepcopy(arg))
+                safe_exc_args.append(arg)
+            except Exception:
+                safe_exc_args.append(safe_repr(arg))
         self.exc_module = exc_module
         self.exc_cls_name = exc_cls_name
-        self.exc_args = exc_args
+        self.exc_args = safe_exc_args
         self.text = text
-        Exception.__init__(self, exc_module, exc_cls_name, exc_args, text)
+        Exception.__init__(self, exc_module, exc_cls_name, safe_exc_args, text)
 
     def restore(self):
         return create_exception_cls(self.exc_cls_name,