示例#1
0
def print_timing(name, start_time):
    """ for debugging: print elapsed time, with start_time = timer(). """
    if debug_print_timing():
        print(name + " took: {:.3} s".format(timer() - start_time))
示例#2
0
if args.show:
    # we have to defer opening in browser until we start up the server
    def show_callback():
        """ callback to open a browser window after server is fully initialized"""
        if show_ulog_file:
            if show_3d_page:
                server.show('/3d?log=' + ulog_file)
            else:
                server.show('/plot_app?log=' + ulog_file)
        else:
            server.show('/upload')

    server.io_loop.add_callback(show_callback)

if debug_print_timing():

    def print_statistics():
        """ print ulog cache info once per hour """
        print_cache_info()
        server.io_loop.call_later(60 * 60, print_statistics)

    server.io_loop.call_later(60, print_statistics)

# run_until_shutdown has been added 0.12.4 and is the preferred start method
run_op = getattr(server, "run_until_shutdown", None)
if callable(run_op):
    server.run_until_shutdown()
else:
    server.start()