From a0720a3ced66e8713106fcddeff8aded26922601 Mon Sep 17 00:00:00 2001 From: yukirin Date: Sun, 15 Mar 2015 19:26:03 +0900 Subject: [PATCH] Python3 compatibility --- demos/benchmark/app.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/demos/benchmark/app.py b/demos/benchmark/app.py index edcb6f3..4d7d91d 100644 --- a/demos/benchmark/app.py +++ b/demos/benchmark/app.py @@ -1,3 +1,7 @@ +from __future__ import print_function + +import sys + import tornadoredis import tornado.httpserver import tornado.web @@ -7,6 +11,10 @@ import redis +PY3 = sys.version > '3' +if PY3: + xrange = range + logging.basicConfig(level=logging.DEBUG) log = logging.getLogger('app') @@ -92,12 +100,12 @@ def get(self): # Start the data initialization routine http_server = tornado.httpserver.HTTPServer(application) http_server.listen(8888) - print 'Benchmark is runing at 0.0.0.0:8888\n' \ - 'Quit the benchmark with CONTROL-C\n' \ - 'Use the following paths for benchmarking:\n' \ - ' / - increment benchmark\n' \ - ' /pool - connection pool benchmark\n' \ - ' /mset - MSET benchmark\n' \ - ' /redis-py/ - increment benchmark\n' \ - ' /redis-py/mset - MSET benchmark' + print('Benchmark is runing at 0.0.0.0:8888\n' + 'Quit the benchmark with CONTROL-C\n' + 'Use the following paths for benchmarking:\n' + ' / - increment benchmark\n' + ' /pool - connection pool benchmark\n' + ' /mset - MSET benchmark\n' + ' /redis-py/ - increment benchmark\n' + ' /redis-py/mset - MSET benchmark') tornado.ioloop.IOLoop.instance().start()