Skip to content

Commit

Permalink
fix(agent): log exception instead of returning (revert #121)
Browse files Browse the repository at this point in the history
We need to keep backward compatibility with older clients and they will
have trouble unpickling a new exception, as we are sending these out
pickled by reference and not by value (solving that would require
serialization backend specific actions, which I would rather avoid
for now to unblock a release).
  • Loading branch information
efiop committed May 22, 2024
1 parent ad82211 commit 5dd22b5
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/isolate/connections/grpc/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from dataclasses import dataclass
from typing import (
Any,
Generator,
Iterable,
Iterator,
)
Expand Down Expand Up @@ -66,7 +65,7 @@ def Run(
self.log(
"The setup function has thrown an error. Aborting the run."
)
yield from self.send_object(
yield self.send_object(
request.setup_func.method,
result,
was_it_raised,
Expand All @@ -87,7 +86,7 @@ def Run(
"function",
extra_args=extra_args,
)
yield from self.send_object(
yield self.send_object(
request.function.method,
result,
was_it_raised,
Expand All @@ -113,8 +112,11 @@ def execute_function(
# NOTE: technically any sort of exception could be raised here, since
# depickling is basically involves code execution from the *user*.
function = from_grpc(function)
except BaseException as exc:
return exc, True, traceback.format_exc()
except BaseException:
self.log(traceback.format_exc())
raise AbortException(
f"The {function_kind} function could not be deserialized."
)

if not callable(function):
raise AbortException(
Expand Down Expand Up @@ -143,7 +145,7 @@ def send_object(
result: object,
was_it_raised: bool,
stringized_tb: str | None,
) -> Generator[definitions.PartialRunResult, None, Any]:
) -> definitions.PartialRunResult:
try:
definition = serialize_object(serialization_method, result)
except SerializationError:
Expand All @@ -166,7 +168,7 @@ def send_object(
was_it_raised=was_it_raised,
stringized_traceback=stringized_tb,
)
yield definitions.PartialRunResult(
return definitions.PartialRunResult(
result=serialized_obj,
is_complete=True,
logs=[],
Expand Down

0 comments on commit 5dd22b5

Please sign in to comment.