diff --git a/src/isolate/connections/grpc/agent.py b/src/isolate/connections/grpc/agent.py index 9892f60..d9528a5 100644 --- a/src/isolate/connections/grpc/agent.py +++ b/src/isolate/connections/grpc/agent.py @@ -10,7 +10,6 @@ from dataclasses import dataclass from typing import ( Any, - Generator, Iterable, Iterator, ) @@ -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, @@ -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, @@ -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( @@ -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: @@ -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=[],