Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dikt = __main__.__dict__
return self.runctx(cmd, dikt, dikt)
class ThreadProfile(Profile):
"""
threading.Thread-aware version of Profile class.
Threads started after enable() call will be profiled.
After disable() call, threads will need to be switched into and trigger a
trace event (typically a "line" event) before they can notice the
disabling.
"""
__slots__ = ('_local_trace_backup', )
stack = LocalDescriptor(_initStack)
global_dict = LocalDescriptor(dict)
def __init__(self, **kw):
super(ThreadProfile, self).__init__(**kw)
self._local_trace_backup = self._local_trace
def _enable(self):
self._local_trace = self._local_trace_backup
threading.settrace(self._global_trace)
super(ThreadProfile, self)._enable()
def _disable(self):
super(ThreadProfile, self)._disable()
threading.settrace(None)
self._local_trace = None
class StatisticProfile(ProfileBase, ProfileRunnerBase):
def __init__(self, func=None):
"""
func (callable)
If provided, called when a missing property is accessed
(ex: accessing thread never initialised that property).
If None, AttributeError is raised.
"""
super(LocalDescriptor, self).__init__()
if func is not None:
self.func = func
import __main__
dikt = __main__.__dict__
return self.runctx(cmd, dikt, dikt)
class ThreadProfile(Profile):
"""
threading.Thread-aware version of Profile class.
Threads started after enable() call will be profiled.
After disable() call, threads will need to be switched into and trigger a
trace event (typically a "line" event) before they can notice the
disabling.
"""
__slots__ = ('_local_trace_backup', )
stack = LocalDescriptor(_initStack)
global_dict = LocalDescriptor(dict)
def __init__(self, **kw):
super(ThreadProfile, self).__init__(**kw)
self._local_trace_backup = self._local_trace
def _enable(self):
self._local_trace = self._local_trace_backup
threading.settrace(self._global_trace)
super(ThreadProfile, self)._enable()
def _disable(self):
super(ThreadProfile, self)._disable()
threading.settrace(None)
self._local_trace = None