diff --git a/osprofiler/profiler.py b/osprofiler/profiler.py index fcbbc38..1290f51 100644 --- a/osprofiler/profiler.py +++ b/osprofiler/profiler.py @@ -31,7 +31,7 @@ from osprofiler import notifier __local_ctx = threading.local() -def _clean(): +def clean(): __local_ctx.profiler = None diff --git a/osprofiler/tests/unit/test_profiler.py b/osprofiler/tests/unit/test_profiler.py index 96f0654..1bd4b3f 100644 --- a/osprofiler/tests/unit/test_profiler.py +++ b/osprofiler/tests/unit/test_profiler.py @@ -28,7 +28,7 @@ from osprofiler.tests import test class ProfilerGlobMethodsTestCase(test.TestCase): def test_get_profiler_not_inited(self): - profiler._clean() + profiler.clean() self.assertIsNone(profiler.get()) def test_get_profiler_and_init(self): @@ -40,7 +40,7 @@ class ProfilerGlobMethodsTestCase(test.TestCase): self.assertEqual(p.get_id(), "2") def test_start_not_inited(self): - profiler._clean() + profiler.clean() profiler.start("name") def test_start(self): @@ -50,7 +50,7 @@ class ProfilerGlobMethodsTestCase(test.TestCase): p.start.assert_called_once_with("name", info="info") def test_stop_not_inited(self): - profiler._clean() + profiler.clean() profiler.stop() def test_stop(self): diff --git a/osprofiler/tests/unit/test_web.py b/osprofiler/tests/unit/test_web.py index 24b3906..61015cb 100644 --- a/osprofiler/tests/unit/test_web.py +++ b/osprofiler/tests/unit/test_web.py @@ -31,8 +31,8 @@ class WebTestCase(test.TestCase): def setUp(self): super(WebTestCase, self).setUp() - profiler._clean() - self.addCleanup(profiler._clean) + profiler.clean() + self.addCleanup(profiler.clean) def test_get_trace_id_headers_no_hmac(self): profiler.init(None, base_id="y", parent_id="z") @@ -61,10 +61,10 @@ class WebTestCase(test.TestCase): class WebMiddlewareTestCase(test.TestCase): def setUp(self): super(WebMiddlewareTestCase, self).setUp() - profiler._clean() + profiler.clean() # it's default state of _ENABLED param, so let's set it here web._ENABLED = None - self.addCleanup(profiler._clean) + self.addCleanup(profiler.clean) def tearDown(self): web.enable() diff --git a/osprofiler/web.py b/osprofiler/web.py index 2c9fc53..8443ca5 100644 --- a/osprofiler/web.py +++ b/osprofiler/web.py @@ -131,4 +131,4 @@ class WsgiMiddleware(object): with profiler.Trace(self.name, info=info): return request.get_response(self.application) finally: - profiler._clean() + profiler.clean()