1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-09 01:03:24 +00:00

fix test_tornado_exception_can_be_caught RuntimeError: generator raised StopIteration

This commit is contained in:
Thomas Grainger
2024-01-23 12:14:58 +00:00
parent db1f5b0dee
commit 6d7a842a33

View File

@@ -3,7 +3,6 @@ import contextlib
import copy
import inspect
import logging
import sys
from asyncio import iscoroutinefunction
import wrapt
@@ -126,20 +125,7 @@ class CassetteContextDecorator:
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: