Skip to content

Commit

Permalink
Attach traceback str to subprocess exceptions (#242)
Browse files Browse the repository at this point in the history
* Attach traceback str to subprocess exceptions

* Fix lint
  • Loading branch information
cjrh authored Jan 3, 2025
1 parent 62368ae commit ff26325
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions deadpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,18 @@ def timed_out():
f"{traceback.format_exception(pickle_error)}"
)
e = ProcessError(msg)

# Because we can't retain the traceback (can't be pickled by default,
# an external library like "tblib" would be needed), we're going to
# render the traceback to a string and add that to the exception
# text. This approach also works for when deadpool can be distributed
# across multiple machines, since the traceback is a string.
traceback_str = "".join(
traceback.format_exception(type(e), e, e.__traceback__)
)
# Modify the exception's args to include the traceback
# This changes the string representation of the exception
e.args = (f"{e}\n{traceback_str}",) + e.args[1:]
conn_send_safe(e)
else:
conn_send_safe(results)
Expand Down

0 comments on commit ff26325

Please sign in to comment.