From 50b866cceba83eaf6133d21abda239f3d0ede069 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sun, 7 Dec 2014 10:50:41 -0800 Subject: [PATCH] Use an appropriate ``extract_traceback`` limit When looking for where this modules ``run/load`` ends and the user code begins we only need to search back at most three levels to find this information; so to avoid getting many more frames (especially when they won't be used) then we need to just apply a sensible limit on the levels we get. Change-Id: I9186e8844c92697b7e3f850328b6b39afba0150d --- taskflow/engines/helpers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/taskflow/engines/helpers.py b/taskflow/engines/helpers.py index 9ffff0dc..61a729aa 100644 --- a/taskflow/engines/helpers.py +++ b/taskflow/engines/helpers.py @@ -84,8 +84,9 @@ def _extract_engine(**kwargs): # Figure out where our code ends and the calling code begins (this is # needed since this code is called from two functions in this module, # which means the stack level will vary by one depending on that). - finder = itertools.takewhile(lambda frame: frame[0] in _FILE_NAMES, - reversed(traceback.extract_stack())) + finder = itertools.takewhile( + lambda frame: frame[0] in _FILE_NAMES, + reversed(traceback.extract_stack(limit=3))) stacklevel = sum(1 for _frame in finder) decorator = deprecation.renamed_kwarg('engine_conf', 'engine', version="0.6",