Skip to content

Commit 9cd96cd

Browse files
Merge pull request bryanyang0528#95 from HHArrowood/93-bugfix-pep-479-stopiteration
Handle StopIteration Error
2 parents ba55ae1 + 79dee71 commit 9cd96cd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: ksql/utils.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def parse_columns(columns_str):
8383
def process_row(row, column_names):
8484
row = row.replace(",\n", "").replace("]\n", "")
8585
row_obj = json.loads(row)
86-
if 'finalMessage' in row_obj:
86+
if "finalMessage" in row_obj:
8787
return None
8888
column_values = row_obj["row"]["columns"]
8989
index = 0
@@ -100,12 +100,14 @@ def process_query_result(results, return_objects=None):
100100
yield from results
101101

102102
# parse rows into objects
103-
header = next(results)
103+
try:
104+
header = next(results)
105+
except StopIteration:
106+
return
104107
columns = parse_columns(header)
105108

106109
for result in results:
107110
row_obj = process_row(result, columns)
108111
if row_obj is None:
109112
return
110113
yield row_obj
111-

0 commit comments

Comments
 (0)