Check profiler instance before initialize

Add a small check for this to an prevent issue in Nova [1]
that causes some commands not working.

[1] http://paste.openstack.org/show/641262/

Change-Id: I685386695e13bf5034a1008dbdcff4539eb482d2
Closes-Bug: #1743586
(cherry picked from commit 79e4e2de42)
This commit is contained in:
Tovin Seven 2018-01-18 15:22:07 +07:00
parent 41a6bc3fd4
commit 2eef344306
1 changed files with 3 additions and 2 deletions

View File

@ -55,8 +55,9 @@ def init(hmac_key, base_id=None, parent_id=None):
:param parent_id: Used to build tree of traces.
:returns: Profiler instance
"""
__local_ctx.profiler = _Profiler(hmac_key, base_id=base_id,
parent_id=parent_id)
if get() is None:
__local_ctx.profiler = _Profiler(hmac_key, base_id=base_id,
parent_id=parent_id)
return __local_ctx.profiler