def profile_on(): global p_stats, p_start_time p_stats = {} p_start_time = time() threading.setprofile(profiler) sys.setprofile(profiler)