utils: Group the exceptions in yield_or_abort.
Additionally, the empty yield is rather unnecessary.
This commit is contained in:
@@ -40,22 +40,13 @@ def yield_or_stop(generator):
|
|||||||
generators and handle certain errors.
|
generators and handle certain errors.
|
||||||
|
|
||||||
Since this is also used in streaming responses where we can't just abort
|
Since this is also used in streaming responses where we can't just abort
|
||||||
a request we always yield empty and then raise StopIteration.
|
a request we raise StopIteration.
|
||||||
"""
|
"""
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
yield next(generator)
|
yield next(generator)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
raise
|
raise
|
||||||
except ExperimentalDisabledError:
|
except (ExperimentalDisabledError, EmptyResponseError,
|
||||||
yield
|
ConnectionError, HTTPError):
|
||||||
raise StopIteration
|
|
||||||
except EmptyResponseError:
|
|
||||||
yield
|
|
||||||
raise StopIteration
|
|
||||||
except ConnectionError:
|
|
||||||
yield
|
|
||||||
raise StopIteration
|
|
||||||
except HTTPError:
|
|
||||||
yield
|
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
|
|||||||
Reference in New Issue
Block a user