Catch closed RP, fixes #334.
This commit is contained in:
parent
0c46d9eead
commit
2637254bcf
@ -2,6 +2,7 @@ from hashlib import sha1
|
||||
from urllib.parse import urlparse
|
||||
from collections import OrderedDict
|
||||
from collections.abc import Iterable
|
||||
from sqlalchemy.exc import ResourceClosedError
|
||||
|
||||
QUERY_STEP = 1000
|
||||
row_type = OrderedDict
|
||||
@ -19,6 +20,7 @@ def convert_row(row_type, row):
|
||||
|
||||
def iter_result_proxy(rp, step=None):
|
||||
"""Iterate over the ResultProxy."""
|
||||
try:
|
||||
while True:
|
||||
if step is None:
|
||||
chunk = rp.fetchall()
|
||||
@ -28,6 +30,8 @@ def iter_result_proxy(rp, step=None):
|
||||
break
|
||||
for row in chunk:
|
||||
yield row
|
||||
except ResourceClosedError:
|
||||
return
|
||||
|
||||
|
||||
class ResultIter(object):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user