diff --git a/speech/grpc/transcribe_streaming.py b/speech/grpc/transcribe_streaming.py index 9deee8e0355..a4c33747697 100644 --- a/speech/grpc/transcribe_streaming.py +++ b/speech/grpc/transcribe_streaming.py @@ -226,9 +226,11 @@ def main(): listen_print_loop(recognize_stream) recognize_stream.cancel() - except grpc.RpcError: - # This happens because of the interrupt handler - pass + except grpc.RpcError as e: + code = e.code() + # CANCELLED is caused by the interrupt handler, which is expected. + if code is not code.CANCELLED: + raise if __name__ == '__main__':