Skip to content

Commit

Permalink
fix test_tornado_exception_can_be_caught RuntimeError: generator rais…
Browse files Browse the repository at this point in the history
…ed StopIteration
  • Loading branch information
graingert committed Jan 23, 2024
1 parent db1f5b0 commit 2924107
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions vcr/cassette.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,7 @@ def _handle_generator(self, fn):
duration of the generator.
"""
with self as cassette:
coroutine = fn(cassette)
# We don't need to catch StopIteration. The caller (Tornado's
# gen.coroutine, for example) will handle that.
to_yield = next(coroutine)
while True:
try:
to_send = yield to_yield
except Exception:
to_yield = coroutine.throw(*sys.exc_info())
else:
try:
to_yield = coroutine.send(to_send)
except StopIteration:
break
yield from fn(cassette)

def _handle_function(self, fn):
with self as cassette:
Expand Down

0 comments on commit 2924107

Please sign in to comment.