import copy
import functools
import logging
+import pickle
import sys
import time
from collections import namedtuple
# T instead of (T -> r) -> r. Therefore we need to store the first promise here.
self._first_promise = _first_promise or self # type: '_Promise'
+ @property
+ def _exception(self):
+ # type: () -> Optional[Exception]
+ return getattr(self, '_exception_', None)
+
+ @_exception.setter
+ def _exception(self, e):
+ self._exception_ = e
+ self._serialized_exception_ = pickle.dumps(e) if e is not None else None
+
+ @property
+ def _serialized_exception(self):
+ # type: () -> Optional[bytes]
+ return getattr(self, '_serialized_exception_', None)
+
+
+
@property
def _on_complete(self):
# type: () -> Optional[Callable]
# type: () -> Optional[Exception]
return self._last_promise()._exception
+ @property
+ def serialized_exception(self):
+ # type: () -> Optional[bytes]
+ return self._last_promise()._serialized_exception
+
@property
def has_result(self):
# type: () -> bool
:raises OrchestratorError: Some user error or a config error.
:raises Exception: Some internal error
"""
- if c.exception is not None:
+ if c.serialized_exception is not None:
try:
- e = copy.deepcopy(c.exception)
+ e = pickle.loads(c.serialized_exception)
except (KeyError, AttributeError):
raise Exception('{}: {}'.format(type(c.exception), c.exception))
raise e