Skip to content

Commit 239b330

Browse files
committed
Fix internal CI
1 parent 615d0a9 commit 239b330

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/python/grpcio_tests/tests/unit/_reconnect_test.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -270,17 +270,23 @@ def _call_rpc(
270270
logging.info("[CLIENT] Received response=%r", resp)
271271
return resp, None
272272
except grpc.RpcError as err:
273-
if isinstance(err, grpc_channel_internal._InactiveRpcError):
274-
code = err.code()
275-
logging.info(
276-
"[CLIENT] Failed request=%s: code=%s, error=%s",
277-
req,
278-
code.name if code is not None else "(unknown)",
279-
err.debug_error_string(),
280-
)
281-
return None, err
282-
else:
283-
raise
273+
logging.info(
274+
"[CLIENT] Failed request=%s: %s",
275+
req,
276+
self._pretty_print_rpc_error(err),
277+
)
278+
return None, err
279+
280+
@classmethod
281+
def _pretty_print_rpc_error(cls, err: grpc.RpcError) -> str:
282+
if hasattr(grpc_channel_internal, "_InactiveRpcError") and isinstance(
283+
err, grpc_channel_internal._InactiveRpcError
284+
):
285+
code = err.code()
286+
code_name = code.name if code is not None else "(unknown)"
287+
return f"code={code_name}, error={err.debug_error_string()}"
288+
289+
return f"{err!r}"
284290

285291
def _call_until(
286292
self,

0 commit comments

Comments
 (0)