diff --git a/distributed/profile.py b/distributed/profile.py index 5fec069371e..f90ef065949 100644 --- a/distributed/profile.py +++ b/distributed/profile.py @@ -86,8 +86,9 @@ def process(frame, child, state, stop=None): 'description': 'root', 'children': {'...'}} """ - if frame.f_back is not None and (stop is None or not frame.f_back.f_code.co_filename.endswith(stop)): - state = process(frame.f_back, frame, state, stop=stop) + prev = frame.f_back + if prev is not None and (stop is None or not prev.f_code.co_filename.endswith(stop)): + state = process(prev, frame, state, stop=stop) ident = identifier(frame)