MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / _ExceptionWrapper

Class _ExceptionWrapper

imperative/python/megengine/data/tools/_queue.py:36–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35
36class _ExceptionWrapper:
37 def __init__(self, exc_type=None, exc_msg=None, where="in background"):
38 self.exc_type = exc_type
39 self.exc_msg = exc_msg
40 self.where = where
41
42 def reraise(self):
43 if self.exc_type == "PlasmaStoreFull" or self.exc_type == queue.Full:
44 msg = "Caught {} {}.\nSolution: {}".format(
45 self.exc_type,
46 self.where,
47 'Because of PlasmaStore out of memory, so you can fix it by using: os.environ["MGE_PLASMA_MEMORY"] = x000000000(4GB for default) or reduce the number-workers',
48 )
49 raise RuntimeError(msg)
50 elif self.exc_type == "ObjectIDGetError":
51 logger.warning(
52 "ObjectID not found in plasma store, some data will be lost, try to reduce the number-workers for debugging!"
53 )
54 return
55 else:
56 msg = "Caught {} {}.\nOriginal {}".format(
57 self.exc_type, self.where, self.exc_msg
58 )
59 raise RuntimeError(msg)
60
61 @staticmethod
62 def _serialize_Exception(val):
63 return {"exc_type": val.exc_type, "exc_msg": val.exc_msg, "where": val.where}
64
65 @staticmethod
66 def _deserialize_Exception(data):
67 return _ExceptionWrapper(data["exc_type"], data["exc_msg"], data["where"])
68
69
70class _PlasmaStoreManager:

Callers 3

_worker_loopFunction · 0.85
get_errorMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected