Fix issue with exception being out of scope in Python 3.

pull/20314/head
Robert Bradshaw 5 years ago
parent 74f8da0ae9
commit 147d7c1ec5
  1. 3
      src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/resolver.pyx.pxi
  2. 3
      src/python/grpcio/grpc/_cython/_cygrpc/aio/iomgr/socket.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(
<grpc_custom_resolver*>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):

@ -45,6 +45,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
@ -61,7 +62,7 @@ cdef class _AsyncioSocket:
else:
self._grpc_connect_cb(
<grpc_custom_socket*>self._grpc_socket,
grpc_socket_error("connect {}".format(str(e)).encode())
grpc_socket_error("connect {}".format(error_msg).encode())
)
def _read_cb(self, future):

Loading…
Cancel
Save