MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / _ExceptionWrapper

Class _ExceptionWrapper

tensorpack/dataflow/parallel.py:30–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28
29# from https://github.com/pytorch/pytorch/blob/master/torch/utils/data/_utils/__init__.py
30class _ExceptionWrapper:
31 MAGIC = b"EXC_MAGIC"
32 """Wraps an exception plus traceback to communicate across threads"""
33 def __init__(self, exc_info):
34 # It is important that we don't store exc_info, see
35 # NOTE [ Python Traceback Reference Cycle Problem ]
36 self.exc_type = exc_info[0]
37 self.exc_msg = "".join(traceback.format_exception(*exc_info))
38
39 def pack(self):
40 return self.MAGIC + pickle.dumps(self)
41
42 @staticmethod
43 def unpack(dp):
44 if isinstance(dp, bytes) and dp.startswith(_ExceptionWrapper.MAGIC):
45 return pickle.loads(dp[len(_ExceptionWrapper.MAGIC):])
46
47
48def _repeat_iter(get_itr):

Callers 1

runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected