Example #1
0
def enableProfiler(signum, config):
    """
    Enables the profiler on specified signal
    """
    try:
        # If the profiler is available on the system then enable it
        import gevent_profiler
        
        if config.has_key('summaryOutput'):
            gevent_profiler.set_summary_output(config['summaryOutput'])

        if config.has_key('statsOutput'):
            gevent_profiler.set_stats_output(config['statsOutput'])

        if config.has_key('traceOutput'):
            gevent_profiler.set_trace_output(config['traceOutput'])

        if config.has_key('printPercentage'):
            gevent_profiler.print_percentages(config['printPercentage'])

        if config.has_key('countTimeBlocking'):
            gevent_profiler.time_blocking(config['countTimeBlocking'])

        gevent_profiler.attach_on_signal(signum=signum, duration=config['duration'])
        logging.getLogger().info("The profiler is enabled and waiting on signal %s." % signum)

    except Exception as ex:
        logging.getLogger().warn("Failed enabling the profiler: %s" % ex)
Example #2
0
def main():
	monkey.patch_all()

	tasks = []

	gevent_profiler.attach_on_signal(duration=5)

	while True:
		for x in range(3):
			y = gevent.spawn(task)
			tasks.append(y)
		
		gevent.joinall(tasks)
Example #3
0
def main():
    monkey.patch_all()

    tasks = []

    gevent_profiler.attach_on_signal(duration=5)

    while True:
        for x in range(3):
            y = gevent.spawn(task)
            tasks.append(y)

        gevent.joinall(tasks)
Example #4
0
File: main.py Project: fcua/x8623
    from session.regions import run_region_reloader
    gevent.spawn(run_region_reloader)


try:
    from uwsgidecorators import postfork
except ImportError:
    import gevent.monkey
    gevent.monkey.patch_all()
    init()
else:
    init = postfork(init)

from .app import application

if __name__ == '__main__':
    import settings
    import gevent_profiler
    import signal
    from gevent.pywsgi import WSGIServer

    gevent_profiler.attach_on_signal(signum=signal.SIGUSR1, duration=30)
    gevent_profiler.set_stats_output('stats.txt')
    gevent_profiler.set_summary_output('summary.txt')
    gevent_profiler.set_trace_output('trace.txt')

    logger.info('listening %s:%d', settings.SESSION['host'],
                settings.SESSION['port'])
    WSGIServer((settings.SESSION['host'], settings.SESSION['port']),
               application).serve_forever()