Skip to content

Commit af34a7b

Browse files
committed
pass the desired frame to traceback.walk_stack for 3.11
see python/cpython#96092 and it's not really intended for use outside of StackSummary.extract, see python/cpython#99015 (comment)
1 parent f5e3562 commit af34a7b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

distributed/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2910,7 +2910,7 @@ def run(
29102910
)
29112911

29122912
@staticmethod
2913-
def _get_computation_code(stacklevel=None) -> str:
2913+
def _get_computation_code(stacklevel: int | None = None) -> str:
29142914
"""Walk up the stack to the user code and extract the code surrounding
29152915
the compute/submit/persist call. All modules encountered which are
29162916
ignored through the option
@@ -2921,7 +2921,6 @@ def _get_computation_code(stacklevel=None) -> str:
29212921
``stacklevel`` may be used to explicitly indicate from which frame on
29222922
the stack to get the source code.
29232923
"""
2924-
29252924
ignore_modules = dask.config.get(
29262925
"distributed.diagnostics.computations.ignore-modules"
29272926
)
@@ -2939,7 +2938,8 @@ def _get_computation_code(stacklevel=None) -> str:
29392938
else:
29402939
# stacklevel 0 or less - shows dask internals which likely isn't helpful
29412940
stacklevel = stacklevel if stacklevel > 0 else 1
2942-
for i, (fr, _) in enumerate(traceback.walk_stack(None), 1):
2941+
2942+
for i, (fr, _) in enumerate(traceback.walk_stack(sys._getframe().f_back), 1):
29432943
if stacklevel is not None:
29442944
if i != stacklevel:
29452945
continue

0 commit comments

Comments
 (0)