pull/21954/head
Richard Belleville 5 years ago
parent 753ab16ebb
commit 67a492c946
  1. 10
      src/python/grpcio/grpc/_simple_stubs.py

@ -18,7 +18,8 @@ import datetime
import os
import logging
import threading
from typing import Any, AnyStr, Callable, Iterator, OrderedDict, Optional, Sequence, Tuple, TypeVar, Union
from typing import (Any, AnyStr, Callable, Iterator, OrderedDict, Optional,
Sequence, Tuple, TypeVar, Union)
import grpc
@ -26,7 +27,8 @@ RequestType = TypeVar('RequestType')
ResponseType = TypeVar('ResponseType')
OptionsType = Sequence[Tuple[str, str]]
CacheKey = Tuple[str, OptionsType, Optional[grpc.ChannelCredentials], Optional[grpc.Compression]]
CacheKey = Tuple[str, OptionsType, Optional[grpc.ChannelCredentials], Optional[
grpc.Compression]]
_LOGGER = logging.getLogger(__name__)
@ -67,6 +69,7 @@ def _create_channel(target: str, options: Sequence[Tuple[str, str]],
options=options,
compression=compression)
class ChannelCache:
# NOTE(rbellevi): Untyped due to reference cycle.
_singleton = None
@ -93,7 +96,8 @@ class ChannelCache:
def _evict_locked(self, key: CacheKey):
channel, _ = self._mapping.pop(key)
_LOGGER.debug("Evicting channel %s with configuration %s.", channel, key)
_LOGGER.debug("Evicting channel %s with configuration %s.", channel,
key)
channel.close()
del channel

Loading…
Cancel
Save