Move line profiling from experimental plugin to profiler module; fix NPE

This commit is contained in:
Dmitry Trofimov
2016-10-18 12:05:34 +02:00
parent 11213da218
commit eeb0b0175f
+7 -4
View File
@@ -1,10 +1,10 @@
import os
import shutil
import tempfile
import vmprof
import os
import six
from _prof_imports import TreeStats, CallTreeStat
import tempfile
import shutil
class VmProfProfile(object):
@@ -30,7 +30,10 @@ class VmProfProfile(object):
if not os.path.exists(self.basepath):
os.makedirs(self.basepath)
self.file = tempfile.NamedTemporaryFile(delete=False, dir=self.basepath)
vmprof.enable(self.file.fileno())
try:
vmprof.enable(self.file.fileno(), lines=True)
except:
vmprof.enable(self.file.fileno())
self.is_enabled = True
def disable(self):