[libpeas] Cleanup internal Python hooks code a bit



commit 4431baa5124c8a338e0036c8d304dc25128c48ae
Author: Garrett Regier <garrettregier gmail com>
Date:   Mon Sep 8 22:58:33 2014 -0700

    Cleanup internal Python hooks code a bit

 .../python/peas-plugin-loader-python-internal.py   |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/loaders/python/peas-plugin-loader-python-internal.py 
b/loaders/python/peas-plugin-loader-python-internal.py
index df07cb9..27838a8 100644
--- a/loaders/python/peas-plugin-loader-python-internal.py
+++ b/loaders/python/peas-plugin-loader-python-internal.py
@@ -31,8 +31,8 @@ class Hooks(object):
         if not self.profiling_enabled:
             return
 
-        sort = os.getenv('PEAS_PYTHON_PROFILE')
-        self.stat_sort = ('time',) if sort == '' else sort.split(';')
+        sort = os.getenv('PEAS_PYTHON_PROFILE', default='time')
+        self.stat_sort = sort.split(';')
 
         self.stats = None
         self.stats_lock = threading.Lock()
@@ -46,6 +46,8 @@ class Hooks(object):
         self.profile.enable()
 
     def add_stats(self, profile):
+        profile.disable()
+
         with self.stats_lock:
             if self.stats is None:
                 self.stats = pstats.Stats(profile)
@@ -60,7 +62,6 @@ class Hooks(object):
         thread_profile = cProfile.Profile()
 
         def thread_finished(thread_ref):
-            thread_profile.disable()
             self.add_stats(thread_profile)
 
             self.thread_refs.remove(thread_ref)
@@ -79,7 +80,6 @@ class Hooks(object):
         if not self.profiling_enabled:
             return
 
-        self.profile.disable()
         self.add_stats(self.profile)
 
         with self.stats_lock:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]