Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mock server: show more info when a call fails #128

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions src/dispatch/test/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import dispatch.sdk.v1.function_pb2 as function_pb
import dispatch.sdk.v1.poll_pb2 as poll_pb
from dispatch.id import DispatchID
from dispatch.proto import Status
from dispatch.proto import CallResult, Error, Status
from dispatch.test import EndpointClient

_default_retry_on_status = {
Expand Down Expand Up @@ -172,11 +172,27 @@ def dispatch_calls(self):
if status == Status.OK:
logger.info("call to function %s succeeded", request.function)
else:
logger.warning(
"call to function %s failed (%s)",
request.function,
status,
)
exc = None
if response.HasField("exit"):
if response.exit.HasField("result"):
result = response.exit.result
if result.HasField("error"):
exc = Error._from_proto(result.error).to_exception()

if exc is not None:
logger.warning(
"call to function %s failed (%s => %s: %s)",
request.function,
status,
exc.__class__.__name__,
str(exc),
)
else:
logger.warning(
"call to function %s failed (%s)",
request.function,
status,
)

if status in self.retry_on_status:
_next_queue.append((dispatch_id, request, CallType.RETRY))
Expand Down