summaryrefslogtreecommitdiffstats
path: root/src/osmo_gsm_tester/log.py
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2018-02-12 09:07:05 +0000
committerPau Espin Pedrol <pespin@sysmocom.de>2018-02-13 10:49:00 +0000
commit257ee10967ab61d497cd207ed38b3fcd564bb79c (patch)
treea16fd61d40cad8a5fb75d6bd9d307375f4b5069e /src/osmo_gsm_tester/log.py
parent4792f40f6a05b33a61f8eaec936c233213ebe55d (diff)
log: Use sys._getframe() to avoid stat(2) calls
The Osmo MS driver is launching many many processes and I would like to use the logging framework for the code as well. Unfortunately the inspect/traceback code will use a linecache which will execute stat(2) on one or more python files. Related: OS#2927 Change-Id: I8f6bacadcf74d3aa25db1e1f41644f64aa19cf92
Diffstat (limited to 'src/osmo_gsm_tester/log.py')
-rw-r--r--src/osmo_gsm_tester/log.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/osmo_gsm_tester/log.py b/src/osmo_gsm_tester/log.py
index a9f16c2..7c4ae44 100644
--- a/src/osmo_gsm_tester/log.py
+++ b/src/osmo_gsm_tester/log.py
@@ -275,8 +275,10 @@ def large_separator(*msgs, sublevel=1, space_above=True):
target.large_separator(*msgs, sublevel=sublevel, space_above=space_above)
def get_src_from_caller(levels_up=1):
- caller = getframeinfo(stack()[levels_up][0])
- return '%s:%d' % (os.path.basename(caller.filename), caller.lineno)
+ # Poke into internal to avoid hitting the linecache which will make one or
+ # more calls to stat(2).
+ frame = sys._getframe(levels_up)
+ return '%s:%d' % (os.path.basename(frame.f_code.co_filename), frame.f_lineno)
def get_src_from_exc_info(exc_info=None, levels_up=1):
if exc_info is None: