MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / tracer_fn

Method tracer_fn

tools/trace_orm_adapter.py:84–113  ·  view source on GitHub ↗
(fn, arg)

Source from the content-addressed store, hash-verified

82 adapter_desc = f"{adapter.__class__.__name__}({adapter.role.name})"
83
84 def tracer_fn(fn, arg):
85 nonlocal line_no
86
87 line_no += 1
88
89 print(f"{indent} {line_no} {adapter_desc}", file=REAL_STDOUT)
90 sub_indent = " " * len(f"{line_no} ")
91
92 print(
93 f"{indent}{sub_indent} -> "
94 f"{meth} {_orm_adapter_trace_print(arg)}",
95 file=REAL_STDOUT,
96 )
97 ctx["line_no"] = line_no
98 ret = fn(arg)
99
100 if DEBUG_ADAPT_STEP == line_no:
101 breakpoint()
102
103 if ret is arg:
104 print(f"{indent} {line_no} <- same object", file=REAL_STDOUT)
105 else:
106 print(
107 f"{indent} {line_no} <- {_orm_adapter_trace_print(ret)}",
108 file=REAL_STDOUT,
109 )
110
111 if last_depth == 0:
112 print("", file=REAL_STDOUT)
113 return ret
114
115 try:
116 yield tracer_fn

Callers

nothing calls this directly

Calls 1

_orm_adapter_trace_printFunction · 0.85

Tested by

no test coverage detected