-
Notifications
You must be signed in to change notification settings - Fork 751
Description
Describe your environment
N/A
What happened?
The gRPC channel is not being closed properly, preventing gRPC from shutting down cleanly.
Steps to Reproduce
Please refer to: grpc/grpc#38490 (comment)
Expected Result
gRPC cleanly shutting down.
Actual Result
gRPC not cleanly shutting down.
Additional context
In OTLPExporterMixin
, gRPC channel was created directly and passed to _client
:
Lines 245 to 260 in a7fe4f8
if insecure: | |
self._client = self._stub( | |
insecure_channel(self._endpoint, compression=compression) | |
) | |
else: | |
credentials = _get_credentials( | |
credentials, | |
OTEL_EXPORTER_OTLP_CERTIFICATE, | |
OTEL_EXPORTER_OTLP_CLIENT_KEY, | |
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE, | |
) | |
self._client = self._stub( | |
secure_channel( | |
self._endpoint, credentials, compression=compression | |
) | |
) |
But the channel was not shutdown in shutdown
method:
Lines 356 to 363 in a7fe4f8
def shutdown(self, timeout_millis: float = 30_000, **kwargs) -> None: | |
if self._shutdown: | |
logger.warning("Exporter already shutdown, ignoring call") | |
return | |
# wait for the last export if any | |
self._export_lock.acquire(timeout=timeout_millis / 1e3) | |
self._shutdown = True | |
self._export_lock.release() |
gRPC channel should be closed explicitly with context manager or by calling channel.close()
method, example usage:
https://github.com/grpc/grpc/blob/822f9b15191840228d17dc0d305887374150150e/examples/python/helloworld/greeter_client.py#L25-L33
If not explicitly closed, the gRPC channel may prevent gRPC from shutting down cleanly, leading to issues like the one described in: grpc/grpc#38490
Would you like to implement a fix?
None