From e815ad2e0042f42e926b9c21267bef0287830a2e Mon Sep 17 00:00:00 2001 From: Ritesh Ghorse Date: Mon, 9 Oct 2023 14:14:07 -0400 Subject: [PATCH] Catch EOFError along with StopIteration (#28896) * catch EOF instead of StopIteration * add stop iteration to close * catch both stop iteration and EOF --- sdks/python/apache_beam/io/gcp/bigquery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdks/python/apache_beam/io/gcp/bigquery.py b/sdks/python/apache_beam/io/gcp/bigquery.py index 986919fd6b82..184138af7525 100644 --- a/sdks/python/apache_beam/io/gcp/bigquery.py +++ b/sdks/python/apache_beam/io/gcp/bigquery.py @@ -1310,7 +1310,7 @@ def __iter__(self): def __next__(self): try: return fastavro.schemaless_reader(self.bytes_reader, self.avro_schema) - except StopIteration: + except (StopIteration, EOFError): self.read_rows_response = next(self.read_rows_iterator, None) if self.read_rows_response is not None: self.bytes_reader = io.BytesIO(