def __init__(self, app, conf): self.app = app self.logger = get_logger(conf, log_route='profile') self.log_filename_prefix = conf.get('log_filename_prefix', DEFAULT_PROFILE_PREFIX) dirname = os.path.dirname(self.log_filename_prefix) # Notes: this effort may fail due to permission denied. # it is better to be created and authorized to current # user in advance. if not os.path.exists(dirname): os.makedirs(dirname) self.dump_interval = float(conf.get('dump_interval', 5.0)) self.dump_timestamp = config_true_value( conf.get('dump_timestamp', 'no')) self.flush_at_shutdown = config_true_value( conf.get('flush_at_shutdown', 'no')) self.path = conf.get('path', '__profile__').replace('/', '') self.unwind = config_true_value(conf.get('unwind', 'no')) self.profile_module = conf.get('profile_module', 'eventlet.green.profile') self.profiler = get_profiler(self.profile_module) self.profile_log = ProfileLog(self.log_filename_prefix, self.dump_timestamp) self.viewer = HTMLViewer(self.path, self.profile_module, self.profile_log) self.dump_pool = GreenPool(1000) self.last_dump_at = None