mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Log correct context
This commit is contained in:
parent
3e4272961a
commit
ec0596f2ab
@ -117,7 +117,7 @@ def _check_yield_points(f, changes, start_context):
|
|||||||
|
|
||||||
gen = f(*args, **kwargs)
|
gen = f(*args, **kwargs)
|
||||||
|
|
||||||
last_yield_line_no = 1
|
last_yield_line_no = gen.gi_frame.f_lineno
|
||||||
result = None
|
result = None
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
@ -136,7 +136,7 @@ def _check_yield_points(f, changes, start_context):
|
|||||||
" in %s between %d and end of func"
|
" in %s between %d and end of func"
|
||||||
% (
|
% (
|
||||||
f.__qualname__,
|
f.__qualname__,
|
||||||
start_context,
|
expected_context,
|
||||||
LoggingContext.current_context(),
|
LoggingContext.current_context(),
|
||||||
f.__code__.co_filename,
|
f.__code__.co_filename,
|
||||||
last_yield_line_no,
|
last_yield_line_no,
|
||||||
@ -148,22 +148,22 @@ def _check_yield_points(f, changes, start_context):
|
|||||||
|
|
||||||
frame = gen.gi_frame
|
frame = gen.gi_frame
|
||||||
|
|
||||||
if isinstance(d, defer.Deferred):
|
if isinstance(d, defer.Deferred) and not d.called:
|
||||||
# This happens if we yield on a deferred that doesn't follow
|
# This happens if we yield on a deferred that doesn't follow
|
||||||
# the log context rules without wrappin in a `make_deferred_yieldable`
|
# the log context rules without wrappin in a `make_deferred_yieldable`
|
||||||
if LoggingContext.current_context() != LoggingContext.Sentinel:
|
if LoggingContext.current_context() is not LoggingContext.sentinel:
|
||||||
err = (
|
err = (
|
||||||
"%s yielded with context %s rather than Sentinel,"
|
"%s yielded with context %s rather than sentinel,"
|
||||||
" yielded on line %d in %s"
|
" yielded on line %d in %s"
|
||||||
% (
|
% (
|
||||||
frame.f_code.co_name,
|
frame.f_code.co_name,
|
||||||
start_context,
|
|
||||||
LoggingContext.current_context(),
|
LoggingContext.current_context(),
|
||||||
frame.f_lineno,
|
frame.f_lineno,
|
||||||
frame.f_code.co_filename,
|
frame.f_code.co_filename,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
changes.append(err)
|
changes.append(err)
|
||||||
|
# raise Exception(err)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = yield d
|
result = yield d
|
||||||
|
Loading…
Reference in New Issue
Block a user