|
|
@ -79,31 +79,33 @@ def main_unary_with_exception(server_target): |
|
|
|
try: |
|
|
|
try: |
|
|
|
channel.unary_unary(UNARY_UNARY)(_MESSAGE, wait_for_ready=True) |
|
|
|
channel.unary_unary(UNARY_UNARY)(_MESSAGE, wait_for_ready=True) |
|
|
|
except KeyboardInterrupt: |
|
|
|
except KeyboardInterrupt: |
|
|
|
sys.stderr.write("Running signal handler.\n"); sys.stderr.flush() |
|
|
|
sys.stderr.write("Running signal handler.\n") |
|
|
|
|
|
|
|
sys.stderr.flush() |
|
|
|
|
|
|
|
|
|
|
|
sys.stderr.write("Calling Channel.close()"); sys.stderr.flush() |
|
|
|
|
|
|
|
# This call should not hang. |
|
|
|
# This call should not hang. |
|
|
|
channel.close() |
|
|
|
channel.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main_streaming_with_exception(server_target): |
|
|
|
def main_streaming_with_exception(server_target): |
|
|
|
"""Initiate an RPC with wait_for_ready set and no server backing the RPC.""" |
|
|
|
"""Initiate an RPC with wait_for_ready set and no server backing the RPC.""" |
|
|
|
channel = grpc.insecure_channel(server_target) |
|
|
|
channel = grpc.insecure_channel(server_target) |
|
|
|
try: |
|
|
|
try: |
|
|
|
channel.unary_stream(UNARY_STREAM)(_MESSAGE, wait_for_ready=True) |
|
|
|
channel.unary_stream(UNARY_STREAM)(_MESSAGE, wait_for_ready=True) |
|
|
|
except KeyboardInterrupt: |
|
|
|
except KeyboardInterrupt: |
|
|
|
sys.stderr.write("Running signal handler.\n"); sys.stderr.flush() |
|
|
|
sys.stderr.write("Running signal handler.\n") |
|
|
|
|
|
|
|
sys.stderr.flush() |
|
|
|
|
|
|
|
|
|
|
|
sys.stderr.write("Calling Channel.close()"); sys.stderr.flush() |
|
|
|
|
|
|
|
# This call should not hang. |
|
|
|
# This call should not hang. |
|
|
|
channel.close() |
|
|
|
channel.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
if __name__ == '__main__': |
|
|
|
parser = argparse.ArgumentParser(description='Signal test client.') |
|
|
|
parser = argparse.ArgumentParser(description='Signal test client.') |
|
|
|
parser.add_argument('server', help='Server target') |
|
|
|
parser.add_argument('server', help='Server target') |
|
|
|
|
|
|
|
parser.add_argument('arity', help='Arity', choices=('unary', 'streaming')) |
|
|
|
parser.add_argument( |
|
|
|
parser.add_argument( |
|
|
|
'arity', help='Arity', choices=('unary', 'streaming')) |
|
|
|
'--exception', |
|
|
|
parser.add_argument( |
|
|
|
help='Whether the signal throws an exception', |
|
|
|
'--exception', help='Whether the signal throws an exception', |
|
|
|
|
|
|
|
action='store_true') |
|
|
|
action='store_true') |
|
|
|
args = parser.parse_args() |
|
|
|
args = parser.parse_args() |
|
|
|
if args.arity == 'unary' and not args.exception: |
|
|
|
if args.arity == 'unary' and not args.exception: |
|
|
|