From 973e83e31e4157dbe38e15aa2af50dcb60e5203e Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 10 Jul 2016 09:54:22 -0400 Subject: [PATCH] demos/benchmark: use current() instead of instance() Improves compatibility with some IOLoop implementations. --- demos/benchmark/benchmark.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/demos/benchmark/benchmark.py b/demos/benchmark/benchmark.py index 6a0354d3..1e8375d7 100755 --- a/demos/benchmark/benchmark.py +++ b/demos/benchmark/benchmark.py @@ -54,7 +54,7 @@ class RootHandler(RequestHandler): pass def handle_sigchld(sig, frame): - IOLoop.instance().add_callback_from_signal(IOLoop.instance().stop) + IOLoop.current().add_callback_from_signal(IOLoop.current().stop) def main(): parse_command_line() @@ -64,6 +64,7 @@ def main(): run() def run(): + io_loop = IOLoop(make_current=True) app = Application([("/", RootHandler)]) port = random.randrange(options.min_port, options.max_port) app.listen(port, address='127.0.0.1') @@ -78,10 +79,9 @@ def run(): args.append("-q") args.append("http://127.0.0.1:%d/" % port) subprocess.Popen(args) - IOLoop.instance().start() - IOLoop.instance().close() - del IOLoop._instance - assert not IOLoop.initialized() + io_loop.start() + io_loop.close() + io_loop.clear_current() if __name__ == '__main__': main()