Fix exception serialisation error
This commit is contained in:
parent
f1a1de5469
commit
8cd3449cff
3 changed files with 11 additions and 5 deletions
|
|
@ -40,7 +40,9 @@ def manage_communication(
|
|||
except Exception as e:
|
||||
if ignore_exceptions:
|
||||
logger.error(
|
||||
f"Exception {e} encountered in input, traceback:\n{traceback.format_exc()}"
|
||||
f"""Exception {e} encountered in input, traceback:\n{
|
||||
traceback.format_exc()
|
||||
}"""
|
||||
)
|
||||
else:
|
||||
raise
|
||||
|
|
@ -51,10 +53,12 @@ def manage_communication(
|
|||
if r.exception is not None:
|
||||
if ignore_exceptions:
|
||||
logger.error(
|
||||
f"Exception {r.exception} encountered in worker, traceback:\n{r.worker_traceback}"
|
||||
f"""Exception {
|
||||
r.exception
|
||||
} encountered in worker, traceback:\n{r.worker_traceback}"""
|
||||
)
|
||||
else:
|
||||
raise WorkerException from r.exception
|
||||
raise WorkerException(r.exception)
|
||||
|
||||
if unordered:
|
||||
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ from typing import Any, NamedTuple, Optional
|
|||
class MapResult(NamedTuple):
|
||||
order: int
|
||||
value: Any
|
||||
exception: Optional[Exception] = None
|
||||
exception: Optional[str] = None
|
||||
worker_traceback: Optional[str] = None
|
||||
|
|
|
|||
|
|
@ -57,7 +57,9 @@ def mapper_function(
|
|||
last_chunk.append(MapResult(i, func(value)))
|
||||
except Exception as e:
|
||||
last_chunk.append(
|
||||
MapResult(i, None, e, traceback.format_exc())
|
||||
# `e` has to be stringified in order to avoid any
|
||||
# surprising serialization error when returning it
|
||||
MapResult(i, None, str(e), traceback.format_exc())
|
||||
)
|
||||
except queue.Empty:
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue