Skip to content

Commit 9089d6c

Browse files
authored
Update common_utils.py
When OpenTelemetry intercepts grpc stream calls it returns generator. So in `GrpcWrapperAsyncIO.close` in case of intercepted call `self._stream_call` have no method `cancel` but have method `close`.
1 parent 2ca4de8 commit 9089d6c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ydb/_grpc/grpcwrapper/common_utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,12 @@ async def start(self, driver: SupportedDriverType, stub, method):
174174
def close(self):
175175
self.from_client_grpc.put_nowait(_stop_grpc_connection_marker)
176176
if self._stream_call:
177-
self._stream_call.cancel()
177+
if hasattr(self._stream_call, "cancel"):
178+
# for ordinal grpc calls
179+
self._stream_call.cancel()
180+
elif hasattr(self._stream_call, "close"):
181+
# for OpenTelemetry intercepted grpc calls (generator)
182+
self._stream_call.close()
178183

179184
self._clean_executor(wait=True)
180185

0 commit comments

Comments
 (0)