in mutornadomon/external_interfaces/http_endpoints.py [0:0]
def get(self):
# Dictates whether to stop any on going profiling
if 'stopprofiler' in self.request.arguments:
self.monitor.profiler_init = False
self.monitor.stop_profiler = True
self.write("Stopped Profiling")
return
sortby, profile_time, wait_time = self.set_options()
# If profiling is not started, start it
if self.monitor.profiler_init is False:
self.write("Profiling done for " + str(profile_time * 1000) +
" msec\n")
if self.monitor.profiler is None:
self.monitor.profiler = cProfile.Profile()
else:
self.monitor.profiler.clear()
while True:
# enable proflier for profile_time
self.monitor.profiler_init = True
yield gen.Task(self.monitor.io_loop.add_timeout,
time.time() + profile_time)
# disable profiling
self.disable_profiler()
self.print_profile_data(sortby, wait_time)
# Stop profiling for the duration of the wait_time
yield gen.Task(self.monitor.io_loop.add_timeout,
time.time() + wait_time)
# If wait_time is specified then continue profiling
# All the profiling data will be logged using the logger
if ((wait_time == 0) or (self.monitor.stop_profiler is True)):
break