diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pyx.pxi index 4c102392e5c..d533d6e3a37 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pyx.pxi @@ -35,6 +35,7 @@ cdef class _AsyncioResolver: res = future.result() except Exception as e: error = True + error_msg = str(e) finally: self._task_resolve = None @@ -48,7 +49,7 @@ cdef class _AsyncioResolver: grpc_custom_resolve_callback( self._grpc_resolver, NULL, - grpc_socket_error("getaddrinfo {}".format(str(e)).encode()) + grpc_socket_error("getaddrinfo {}".format(error_msg).encode()) ) cdef void resolve(self, char* host, char* port): diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pyx.pxi index eed496df7c6..4ef755dfaa0 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.pyx.pxi @@ -61,6 +61,7 @@ cdef class _AsyncioSocket: self._reader, self._writer = future.result() except Exception as e: error = True + error_msg = str(e) finally: self._task_connect = None @@ -77,7 +78,7 @@ cdef class _AsyncioSocket: else: self._grpc_connect_cb( self._grpc_socket, - grpc_socket_error("connect {}".format(str(e)).encode()) + grpc_socket_error("connect {}".format(error_msg).encode()) ) def _read_cb(self, future):