Fixing the docstring wording

pull/21621/head
Lidi Zheng 5 years ago
parent f75ce34da7
commit 0afc05cef5
  1. 19
      src/python/grpcio/grpc/experimental/aio/_channel.py
  2. 4
      src/python/grpcio_tests/tests_aio/unit/connectivity_test.py

@ -230,17 +230,14 @@ class Channel:
This is an EXPERIMENTAL API. This is an EXPERIMENTAL API.
It's the nature of connectivity states to change. The returned If the channel reaches a stable connectivity state, it is guaranteed
connectivity state might become obsolete soon. Combining that the return value of this function will eventually converge to that
"Channel.wait_for_state_change" we guarantee the convergence of state.
connectivity state between application and ground truth.
Args: Args: try_to_connect: a bool indicate whether the Channel should try to
try_to_connect: a bool indicate whether the Channel should try to connect to peer or not.
connect to peer or not.
Returns: Returns: A ChannelConnectivity object.
A ChannelConnectivity object.
""" """
result = self._channel.check_connectivity_state(try_to_connect) result = self._channel.check_connectivity_state(try_to_connect)
return _common.CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY.get( return _common.CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY.get(
@ -260,8 +257,8 @@ class Channel:
There is an inherent race between the invocation of There is an inherent race between the invocation of
"Channel.wait_for_state_change" and "Channel.get_state". The state can "Channel.wait_for_state_change" and "Channel.get_state". The state can
arbitrary times during the race, so there is no way to observe every change arbitrary times during the race, so there is no way to observe
state transition. every state transition.
If there is a need to put a timeout for this function, please refer to If there is a need to put a timeout for this function, please refer to
"asyncio.wait_for". "asyncio.wait_for".

@ -100,9 +100,9 @@ class TestConnectivityState(AioTestBase):
self.assertEqual(grpc.ChannelConnectivity.SHUTDOWN, self.assertEqual(grpc.ChannelConnectivity.SHUTDOWN,
channel.get_state(False)) channel.get_state(False))
# It can raise Exception since it is an usage error, but it should not # It can raise exceptions since it is an usage error, but it should not
# segfault or abort. # segfault or abort.
with self.assertRaises(Exception): with self.assertRaises(RuntimeError):
await channel.wait_for_state_change( await channel.wait_for_state_change(
grpc.ChannelConnectivity.SHUTDOWN) grpc.ChannelConnectivity.SHUTDOWN)

Loading…
Cancel
Save