profiling: don't error with statprof when profiling has already started
authorGregory Szorc <gregory.szorc@gmail.com>
Sun, 14 Aug 2016 18:28:43 -0700
changeset 29785 88d3c1ab03a7
parent 29784 e3501546f7e4
child 29786 fc2442492606
profiling: don't error with statprof when profiling has already started statprof.reset() asserts if profiling has already started. So don't call if it profiling is already running.
mercurial/profiling.py
--- a/mercurial/profiling.py	Sun Aug 14 17:51:12 2016 -0700
+++ b/mercurial/profiling.py	Sun Aug 14 18:28:43 2016 -0700
@@ -88,7 +88,9 @@
 
     freq = ui.configint('profiling', 'freq', default=1000)
     if freq > 0:
-        statprof.reset(freq)
+        # Cannot reset when profiler is already active. So silently no-op.
+        if statprof.state.profile_level == 0:
+            statprof.reset(freq)
     else:
         ui.warn(_("invalid sampling frequency '%s' - ignoring\n") % freq)