From ca04202696665e4e4ce338d52e2997076ef99be9 Mon Sep 17 00:00:00 2001 From: Matthew Rocklin Date: Thu, 28 Dec 2017 07:59:00 -0800 Subject: [PATCH] Avoid race condition where frame.f_back is lost during check --- distributed/profile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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)