pull/23163/head
Richard Belleville 5 years ago
parent 50cab884e1
commit 25cdba8a70
  1. 15
      src/python/grpcio/grpc/_simple_stubs.py
  2. 3
      src/python/grpcio/grpc/experimental/__init__.py
  3. 20
      src/python/grpcio_tests/tests_py3_only/unit/_simple_stubs_test.py

@ -173,7 +173,8 @@ class ChannelCache:
def _get_wait_for_ready_settings(wait_for_ready: Optional[bool],
timeout: Optional[float]) -> Tuple[bool, float]:
timeout: Optional[float]
) -> Tuple[bool, float]:
if wait_for_ready is None:
wait_for_ready = True
if wait_for_ready and timeout is None:
@ -251,7 +252,8 @@ def unary_unary(
compression)
multicallable = channel.unary_unary(method, request_serializer,
response_deserializer)
wait_for_ready, timeout = _get_wait_for_ready_settings(wait_for_ready, timeout)
wait_for_ready, timeout = _get_wait_for_ready_settings(
wait_for_ready, timeout)
return multicallable(request,
metadata=metadata,
wait_for_ready=wait_for_ready,
@ -328,7 +330,8 @@ def unary_stream(
compression)
multicallable = channel.unary_stream(method, request_serializer,
response_deserializer)
wait_for_ready, timeout = _get_wait_for_ready_settings(wait_for_ready, timeout)
wait_for_ready, timeout = _get_wait_for_ready_settings(
wait_for_ready, timeout)
return multicallable(request,
metadata=metadata,
wait_for_ready=wait_for_ready,
@ -405,7 +408,8 @@ def stream_unary(
compression)
multicallable = channel.stream_unary(method, request_serializer,
response_deserializer)
wait_for_ready, timeout = _get_wait_for_ready_settings(wait_for_ready, timeout)
wait_for_ready, timeout = _get_wait_for_ready_settings(
wait_for_ready, timeout)
return multicallable(request_iterator,
metadata=metadata,
wait_for_ready=wait_for_ready,
@ -482,7 +486,8 @@ def stream_stream(
compression)
multicallable = channel.stream_stream(method, request_serializer,
response_deserializer)
wait_for_ready, timeout = _get_wait_for_ready_settings(wait_for_ready, timeout)
wait_for_ready, timeout = _get_wait_for_ready_settings(
wait_for_ready, timeout)
return multicallable(request_iterator,
metadata=metadata,
wait_for_ready=wait_for_ready,

@ -42,7 +42,8 @@ class UsageError(Exception):
_insecure_channel_credentials_sentinel = object()
_insecure_channel_credentials = grpc.ChannelCredentials(_insecure_channel_credentials_sentinel)
_insecure_channel_credentials = grpc.ChannelCredentials(
_insecure_channel_credentials_sentinel)
def insecure_channel_credentials():

@ -317,11 +317,8 @@ class SimpleStubsTest(unittest.TestCase):
addr, port, sock = get_socket()
sock.close()
target = f'{addr}:{port}'
channel = grpc._simple_stubs.ChannelCache.get().get_channel(target,
(),
None,
True,
None)
channel = grpc._simple_stubs.ChannelCache.get().get_channel(
target, (), None, True, None)
rpc_finished_event = threading.Event()
rpc_failed_event = threading.Event()
server = None
@ -336,7 +333,8 @@ class SimpleStubsTest(unittest.TestCase):
server.add_generic_rpc_handlers((_GenericHandler(),))
server.start()
channel.unsubscribe(_on_connectivity_changed)
elif connectivity in (grpc.ChannelConnectivity.IDLE, grpc.ChannelConnectivity.CONNECTING):
elif connectivity in (grpc.ChannelConnectivity.IDLE,
grpc.ChannelConnectivity.CONNECTING):
pass
else:
raise AssertionError("Encountered unknown state.")
@ -345,14 +343,12 @@ class SimpleStubsTest(unittest.TestCase):
def _send_rpc():
try:
response = grpc.experimental.unary_unary(
_REQUEST,
target,
_UNARY_UNARY,
insecure=True)
response = grpc.experimental.unary_unary(_REQUEST,
target,
_UNARY_UNARY,
insecure=True)
rpc_finished_event.set()
except Exception as e:
import sys; sys.stderr.write(e); sys.stderr.flush()
rpc_failed_event.set()
t = threading.Thread(target=_send_rpc)

Loading…
Cancel
Save