address comments

pull/16513/head
Eric Gribkoff 6 years ago
parent 2ea6d3ef0b
commit ff0d2195cf
  1. 2
      src/python/grpcio_tests/tests/fork/_fork_interop_test.py
  2. 14
      src/python/grpcio_tests/tests/fork/methods.py

@ -139,7 +139,7 @@ class ForkInteropTest(unittest.TestCase):
out, err = process.communicate() out, err = process.communicate()
except subprocess.TimeoutExpired: except subprocess.TimeoutExpired:
process.kill() process.kill()
raise ValueError('Process failed to terminate') raise RuntimeError('Process failed to terminate')
finally: finally:
timer.cancel() timer.cancel()
self.assertEqual( self.assertEqual(

@ -136,7 +136,7 @@ class _ChildProcess(object):
def finish(self): def finish(self):
self._process.join(timeout=_CHILD_FINISH_TIMEOUT_S) self._process.join(timeout=_CHILD_FINISH_TIMEOUT_S)
if self._process.is_alive(): if self._process.is_alive():
raise ValueError('Child process did not terminate') raise RuntimeError('Child process did not terminate')
if self._process.exitcode != 0: if self._process.exitcode != 0:
raise ValueError('Child process failed with exitcode %d' % raise ValueError('Child process failed with exitcode %d' %
self._process.exitcode) self._process.exitcode)
@ -236,6 +236,9 @@ def _close_channel_before_fork(channel, args):
def _connectivity_watch(channel, args): def _connectivity_watch(channel, args):
parent_states = []
parent_channel_ready_event = threading.Event()
def child_target(): def child_target():
child_channel_ready_event = threading.Event() child_channel_ready_event = threading.Event()
@ -244,7 +247,6 @@ def _connectivity_watch(channel, args):
if state is grpc.ChannelConnectivity.READY: if state is grpc.ChannelConnectivity.READY:
child_channel_ready_event.set() child_channel_ready_event.set()
child_states = []
with _channel(args) as child_channel: with _channel(args) as child_channel:
child_stub = test_pb2_grpc.TestServiceStub(child_channel) child_stub = test_pb2_grpc.TestServiceStub(child_channel)
child_channel.subscribe(child_connectivity_callback) child_channel.subscribe(child_connectivity_callback)
@ -257,9 +259,6 @@ def _connectivity_watch(channel, args):
parent_states) parent_states)
child_channel.unsubscribe(child_connectivity_callback) child_channel.unsubscribe(child_connectivity_callback)
parent_states = []
parent_channel_ready_event = threading.Event()
def parent_connectivity_callback(state): def parent_connectivity_callback(state):
parent_states.append(state) parent_states.append(state)
if state is grpc.ChannelConnectivity.READY: if state is grpc.ChannelConnectivity.READY:
@ -275,11 +274,6 @@ def _connectivity_watch(channel, args):
channel.unsubscribe(parent_connectivity_callback) channel.unsubscribe(parent_connectivity_callback)
child_process.finish() child_process.finish()
# Need to unsubscribe or _channel.py in _poll_connectivity triggers a
# "Cannot invoke RPC on closed channel!" error.
# TODO(ericgribkoff) Fix issue with channel.close() and connectivity polling
channel.unsubscribe(parent_connectivity_callback)
def _ping_pong_with_child_processes_after_first_response( def _ping_pong_with_child_processes_after_first_response(
channel, args, child_target, run_after_close=True): channel, args, child_target, run_after_close=True):

Loading…
Cancel
Save