Skip to content
Snippets Groups Projects
Commit 3e427296 authored by Erik Johnston's avatar Erik Johnston
Browse files

Test for sentinel commit

parent 1d6dd1c2
No related branches found
No related tags found
No related merge requests found
...@@ -146,13 +146,30 @@ def _check_yield_points(f, changes, start_context): ...@@ -146,13 +146,30 @@ def _check_yield_points(f, changes, start_context):
# raise Exception(err) # raise Exception(err)
return getattr(e, "value", None) return getattr(e, "value", None)
frame = gen.gi_frame
if isinstance(d, defer.Deferred):
# This happens if we yield on a deferred that doesn't follow
# the log context rules without wrappin in a `make_deferred_yieldable`
if LoggingContext.current_context() != LoggingContext.Sentinel:
err = (
"%s yielded with context %s rather than Sentinel,"
" yielded on line %d in %s"
% (
frame.f_code.co_name,
start_context,
LoggingContext.current_context(),
frame.f_lineno,
frame.f_code.co_filename,
)
)
changes.append(err)
try: try:
result = yield d result = yield d
except Exception as e: except Exception as e:
result = Failure(e) result = Failure(e)
frame = gen.gi_frame
if LoggingContext.current_context() != expected_context: if LoggingContext.current_context() != expected_context:
# This happens because the context is lost sometime *after* the # This happens because the context is lost sometime *after* the
# previous yield and *after* the current yield. E.g. the # previous yield and *after* the current yield. E.g. the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment