Skip to content

Commit 62954e9

Browse files
jerjouJon Wayne Parrott
authored and
Jon Wayne Parrott
committed
More specific exception swallowing. (#746)
1 parent 9da144a commit 62954e9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

speech/grpc/transcribe_streaming.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,11 @@ def main():
226226
listen_print_loop(recognize_stream)
227227

228228
recognize_stream.cancel()
229-
except grpc.RpcError:
230-
# This happens because of the interrupt handler
231-
pass
229+
except grpc.RpcError as e:
230+
code = e.code()
231+
# CANCELLED is caused by the interrupt handler, which is expected.
232+
if code is not code.CANCELLED:
233+
raise
232234

233235

234236
if __name__ == '__main__':

0 commit comments

Comments
 (0)