def assemble_routes(): """Assembles all routes and returns""" custom_routes = [("/", views.signin.Landing)] api_routes = get_routes(api) view_routes = map( lambda r: (r[0].replace("/views", "", 1), r[1]), get_routes(views) # View routes with /views removed ) return api_routes + view_routes + custom_routes
def assemble_routes(): """Assembles all routes and returns""" # TODO: Change "/" to point to signin.Landing requesthandler once # game view is implemented custom_routes = [("/", views.signin.Landing)] api_routes = get_routes(api) view_routes = map( lambda r: (r[0].replace("/views", "", 1), r[1]), get_routes(views) # View routes with /views removed ) return api_routes + view_routes + custom_routes
def main(): routes = get_routes(api) print("Routes\n======\n\n" + json.dumps([(url, repr(rh)) for url, rh in routes])) app = Application(routes=routes, settings={}, generate_docs=True) app.listen(6060) tornado.ioloop.IOLoop.instance().start()
def make_app(): import blackbean routes = get_routes(blackbean) print("Routes\n=======\n\n" + json.dumps([(url, repr(rh)) for url, rh in routes], indent=2)) settings = {"debug": True} return Application(routes=routes, settings=settings, generate_docs=True)
def make_app(): import helloworld routes = get_routes(helloworld) print("Routes\n=======\n\n" + json.dumps([(url, repr(rh)) for url, rh in routes], indent=2)) settings = {"debug": True, "default_handler_class": NotFoundHandler} return Application(routes=routes, settings=settings, generate_docs=True)
def get_app(self): rts = routes.get_routes(helloworld) rts += [("/api/explodinghandler", ExplodingHandler), ("/views/someview", DummyView), ("/api/dbtest", DBTestHandler)] return application.Application(routes=rts, settings={"debug": True}, db_conn=None)
def __init__(self, logger, config): self.logger = logger self.config = config routes = get_routes(movie) print("Routes\n======\n\n" + json.dumps([(url, repr(rh)) for url, rh in routes], indent=2)) settings = dict( debug=options.debug, xsrf_cookies=False, # TODO: update manually cookie_secret='lpyoGs9/TAuA8IINRTRRjlgBspMDy0lKtvQNGrTnA9g=', ) super(Application, self).__init__(routes=routes, generate_docs=True, settings=settings) # Connect to the keyspace on our cluster running at 127.0.0.1 connection.setup(config.clusterNodes, config.clusterKeyspace, protocol_version=2) # Sync your model with your cql table sync_table(models.Users) sync_table(models.ActorID) sync_table(models.ActorFirst) sync_table(models.ActorLast) sync_table(models.ActorLastFirst) sync_table(models.Movie)
def get_module_api_routes(module): module_path = base_path("modules", module) if os.path.isdir(module_path): api_module = __import__(name=module, fromlist=["api"]) routes = get_routes(api_module) return routes else: return []
def get_app(self): rts = routes.get_routes(helloworld) rts += [ ("/api/explodinghandler", ExplodingHandler), ("/views/someview", DummyView), ("/api/dbtest", DBTestHandler), ] return application.Application(routes=rts, settings={"debug": True}, db_conn=None)
def main(): import cars routes = get_routes(cars) print("Routes\n======\n\n" + json.dumps([(url, repr(rh)) for url, rh in routes], indent=2)) application = Application(routes=routes, settings={}) application.listen(8888) tornado.ioloop.IOLoop.instance().start()
def make_app(): import api routes = get_routes(api) routes = filter(lambda r: r[0].startswith("/api"), routes) # filter other autogenerated urls print("API Routes\n======\n\n" + json.dumps( [(url, repr(rh)) for url, rh in routes], indent=2) ) return Application(routes=routes, settings={}, generate_docs=True)
def test_get_routes(self): """Tests routes.get_routes""" assert sorted(routes.get_routes(helloworld)) == sorted([ ("/api/helloworld/?", helloworld.api.HelloWorldHandler), ("/api/asynchelloworld/?", helloworld.api.AsyncHelloWorld), ("/api/postit/?", helloworld.api.PostIt), ("/api/greeting/(?P<fname>[a-zA-Z0-9_]+)/" "(?P<lname>[a-zA-Z0-9_]+)/?$", helloworld.api.Greeting), ("/api/freewilled/?", helloworld.api.FreeWilledHandler) ]) assert sorted(routes.get_routes(cars)) == sorted([ ("/api/cars/?", cars.api.MakeListHandler), ("/api/cars/(?P<make>[a-zA-Z0-9_]+)/(?P<model>[a-zA-Z0-9_]+)/?$", cars.api.ModelHandler), ("/api/cars/(?P<make>[a-zA-Z0-9_]+)/(?P<model>[a-zA-Z0-9_]+)/" "(?P<year>[a-zA-Z0-9_]+)/?$", cars.api.YearHandler), ("/api/cars/(?P<make>[a-zA-Z0-9_]+)/?$", cars.api.MakeHandler), ])
def main(): routes = get_routes(api) print(routes) application = Application(routes=routes, settings={}) port = config["global"]["listen_port"] application.listen(port) tornado.ioloop.IOLoop.instance().start()
def main(): import hello routes = get_routes(hello) print("Routes\n======\n\n" + json.dumps([(url, repr(rh)) for url, rh in routes], indent=2)) application = Application(routes=routes, settings={}) application.listen(8888) tornado.ioloop.IOLoop.instance().start()
def get_app(self): routes = get_routes(dataservice) print routes settings = dict( hbase_host='192.168.33.10', hbase_thrift_port=9095, hdfs_host='192.168.33.10' ) return Application(routes=routes, settings=settings, db_conn=TestDB())
def get_app(self): rts = routes.get_routes(helloworld) rts += [("/api/people", PeopleHandler), ("/api/foobar", FoobarHandler), ("/api/echocontent", EchoContentHandler), ("/api/explodinghandler", ExplodingHandler), ("/api/notfoundhandler", NotFoundHandler), ("/views/someview", DummyView), ("/api/dbtest", DBTestHandler)] return application.Application(routes=rts, settings={"debug": True}, db_conn=None)
def main(): import tboxs global _default_testenv_list tornado.options.parse_command_line() app = TboxApp(get_routes(tboxs)) _default_testenv_list = app.test_env_list http_server = tornado.httpserver.HTTPServer(app) http_server.listen(options.port, address='127.0.0.1') TaskManager(_default_testenv_list).start() tornado.ioloop.IOLoop.current().start()
def main(): import helloworld routes = get_routes(helloworld) # routes.extend(get_routes(git)) print ("Routes\n======\n\n" + json.dumps([(url, repr(rh)) for url, rh in routes], indent=2)) application = Application(routes=routes, settings={"token": token}) application.listen(port) tornado.ioloop.IOLoop.instance().start()
def main(): import api routes = get_routes(api) print("Routes\n======\n\n" + json.dumps([(url, repr(rh)) for url, rh in routes], indent=2)) # Create the application by passing routes and any settings application = Application(routes=routes, settings={}, generate_docs=True) # Start the application on port 8888 application.listen(8080) tornado.ioloop.IOLoop.instance().start()
def test_get_routes(self): """Tests routes.get_routes""" assert sorted(routes.get_routes( helloworld)) == sorted([ ("/api/helloworld", helloworld.api.HelloWorldHandler), ("/api/asynchelloworld", helloworld.api.AsyncHelloWorld), ("/api/postit", helloworld.api.PostIt), ("/api/greeting/(?P<fname>[a-zA-Z0-9_]+)/(?P<lname>[a-zA-Z0-9_]+)/?$", helloworld.api.Greeting), ("/api/freewilled", helloworld.api.FreeWilledHandler) ])
def main(): import helloworld routes = get_routes(helloworld) # routes.extend(get_routes(git)) print("Routes\n======\n\n" + json.dumps([(url, repr(rh)) for url, rh in routes], indent=2)) application = Application(routes=routes, settings={'token': token}) application.listen(port) tornado.ioloop.IOLoop.instance().start()
def test_get_routes(self): """Tests routes.get_routes""" assert sorted(routes.get_routes( helloworld)) == sorted([ ("/api/helloworld/?", helloworld.api.HelloWorldHandler), ("/api/asynchelloworld/?", helloworld.api.AsyncHelloWorld), ("/api/postit/?", helloworld.api.PostIt), ("/api/greeting/(?P<fname>[a-zA-Z0-9_]+)/" "(?P<lname>[a-zA-Z0-9_]+)/?$", helloworld.api.Greeting), ("/api/freewilled/?", helloworld.api.FreeWilledHandler) ]) assert sorted(routes.get_routes( cars)) == sorted([ ("/api/cars/?", cars.api.MakeListHandler), ("/api/cars/(?P<make>[a-zA-Z0-9_]+)/(?P<model>[a-zA-Z0-9_]+)/?$", cars.api.ModelHandler), ("/api/cars/(?P<make>[a-zA-Z0-9_]+)/(?P<model>[a-zA-Z0-9_]+)/" "(?P<year>[a-zA-Z0-9_]+)/?$", cars.api.YearHandler), ("/api/cars/(?P<make>[a-zA-Z0-9_]+)/?$", cars.api.MakeHandler), ])
def main(port_num): routes = get_routes(api) print("Routes\n======\n\n" + json.dumps([(url, repr(rh)) for url, rh in routes], indent=2)) application = Application(routes=routes, settings={ 'debug': True, }) tasks.update_cache.delay() application.listen(port_num, address='0.0.0.0') tornado.ioloop.IOLoop.instance().start()
def main(): """ Main entry point for my service. :return: """ # pylint: disable=global-statement global APISERVER config.define_options() # Attempt to load config from config file try: parse_config_file("server.conf") except IOError: errmsg = ( "{} doesn't exist or couldn't be opened. Using defaults.".format( options.conf_file_path)) logging.warn(errmsg) logging.info(options.as_dict()) platform = Platform.factory(CLOUDERA) endpoints = platform.discover(options) if not endpoints: logging.error("Failed to discover API endpoints of cluster") db_store = HDBDataStore(endpoints['HDFS'].geturl(), endpoints['HBASE'].geturl(), options.thrift_port, options.datasets_table, options.data_repo) routes = get_routes(dataservice) logging.info("Service Routes %s", routes) settings = dict() APISERVER = tornado.httpserver.HTTPServer( Application(routes=routes, settings=settings, db_conn=db_store)) for port in options.ports: try: logging.debug( "Attempting to bind for dataset dataset on port:%d and address %s", port, options.bind_address) APISERVER.listen(port, options.bind_address) logging.info("Awesomeness is listening on:%s", port) break except socket.error: logging.warn("Not able to bind on port:%d", port) else: logging.warn("No free port available to bind dataset") signal.signal(signal.SIGTERM, sig_handler) signal.signal(signal.SIGINT, sig_handler) # keep collecting dataset tornado.ioloop.PeriodicCallback(db_store.collect, options.sync_period).start() # db_conn2.collect() tornado.ioloop.IOLoop.instance().start()
def main(): # Pass the web app's package the get_routes and it will generate # routes based on the submodule names and ending with lowercase # request handler name (with 'handler' removed from the end of the # name if it is the name). # [("/api/helloworld", helloworld.api.HelloWorldHandler)] routes = get_routes(helloworld) # Create the application by passing routes and any settings application = Application(routes=routes, settings={}) # Start the application on port 8888 application.listen(8888) tornado.ioloop.IOLoop.instance().start()
def main(): os.environ['PST_MAIL_SUBJECT'] = u"[PST Server][log]" import pservers from motorengine import connect import pst.manlog logger = pst.manlog.logger logger.info("Starting PServer....") io_loop = tornado.ioloop.IOLoop.instance() connect('pst', io_loop=io_loop) tornado.options.parse_command_line() http_server = tornado.httpserver.HTTPServer(PServerApp(get_routes(pservers))) http_server.listen(options.port) io_loop.start()
def main(): """ Main entry point for my service. :return: """ # pylint: disable=global-statement global APISERVER config.define_options() # Attempt to load config from config file try: parse_config_file("server.conf") except IOError: errmsg = ("{} doesn't exist or couldn't be opened. Using defaults." .format(options.conf_file_path)) logging.warn(errmsg) logging.info(options.as_dict()) platform = Platform.factory(options.hadoop_distro) endpoints = platform.discover(options) if not endpoints: logging.error("Failed to discover API endpoints of cluster") db_store = HDBDataStore(endpoints['HDFS'].geturl(), endpoints['HBASE'].geturl(), options.thrift_port, options.datasets_table, options.data_repo) routes = get_routes(dataservice) logging.info("Service Routes %s", routes) settings = dict() APISERVER = tornado.httpserver.HTTPServer( Application(routes=routes, settings=settings, db_conn=db_store)) for port in options.ports: try: logging.debug("Attempting to bind for dataset dataset on port:%d and address %s", port, options.bind_address) APISERVER.listen(port, options.bind_address) logging.info("Awesomeness is listening on:%s", port) break except socket.error: logging.warn("Not able to bind on port:%d", port) else: logging.warn("No free port available to bind dataset") signal.signal(signal.SIGTERM, sig_handler) signal.signal(signal.SIGINT, sig_handler) # keep collecting dataset tornado.ioloop.PeriodicCallback(db_store.collect, options.sync_period).start() # db_conn2.collect() tornado.ioloop.IOLoop.instance().start()
def main(): # Pass the web app's package the get_routes and it will generate # routes based on the submodule names and ending with lowercase # request handler name (with 'handler' removed from the end of the # name if it is the name). # [("/api/helloworld", helloworld.api.HelloWorldHandler)] import notes routes = get_routes(notes) print("Routes\n======\n\n" + json.dumps([(url, repr(rh)) for url, rh in routes], indent=2)) # Create the application by passing routes and any settings application = Application(routes=routes, settings={}, generate_docs=True) # Start the application on port 8888 application.listen(8888) tornado.ioloop.IOLoop.instance().start()
def get_app(self): rts = routes.get_routes(helloworld) rts += [ ("/api/people", PeopleHandler), ("/api/foobar", FoobarHandler), ("/api/echocontent", EchoContentHandler), ("/api/explodinghandler", ExplodingHandler), ("/api/notfoundhandler", NotFoundHandler), ("/views/someview", DummyView), ("/api/dbtest", DBTestHandler) ] return application.Application( routes=rts, settings={"debug": True}, db_conn=None )
def main(): os.chdir(os.path.dirname(os.path.abspath(__file__))) wkr = waker() import api routes = get_routes(api) routes.append(("/ws", wsstream.wsstream)) print("Routes\n======\n\n" + json.dumps([(url, repr(rh)) for url, rh in routes], indent=2)) app = Application(routes=routes, settings={}) app.listen(8080) try: IOLoop.instance().start() except (KeyboardInterrupt, SystemExit): logging.info("Interrupted.")
def main(): # Pass the web app's package the get_routes and it will generate # routes based on the submodule names and ending with lowercase # request handler name (with 'handler' removed from the end of the # name if it is the name). # [("/api/helloworld", helloworld.api.HelloWorldHandler)] import ApiFiles routes = get_routes(ApiFiles) print("Routes\n======\n\n" + json.dumps( [(url, repr(rh)) for url, rh in routes], indent=2) ) # Create the application by passing routes and any settings application = Application(routes=routes, settings={}, generate_docs=True) # Start the application on port 8888 application.listen(8888) tornado.ioloop.IOLoop.instance().start()
def main(): tornado.options.parse_command_line() routes = get_routes(picture) print("Routes\n======\n\n" + json.dumps( [(url, repr(rh)) for url, rh in routes], indent=2) ) application = Application(routes=routes, settings={"debug": True, }) application.objects = peewee_async.Manager(database) application.listen(8080) tcelery.setup_nonblocking_producer(on_ready=call_task) io_loop = tornado.ioloop.IOLoop.instance() # connect("nero_gate", host="192.168.1.5", port=27017, connect=False, io_loop=io_loop) 4 # connect("nero_gate", host="192.168.1.5", port=27017, connect=False, io_loop=io_loop) 3 connect("nero_gate", host="192.168.1.5", port=27017) io_loop.start()
def main(port, db, session_timeout_days, cookie_secret, debug): """ - Get options from config file - Gather all routes - Create the server - Start the server """ global http_server enable_pretty_logging() # Create application configuration app_config = Config( port=port, db_file=db, session_timeout_days=session_timeout_days, cookie_secret=cookie_secret, debug=debug ) # Configure and initialize database if debug: wlsports.db.sql_debug(True) wlsports.db.database.bind("sqlite", db, create_db=True) wlsports.db.database.generate_mapping(create_tables=True) # Create sports if they don't exist with db_session: for name, players_per_team in [ ("Basketball", 5), ("Soccer", 11) ]: if not wlsports.db.Sport.get(name=name): wlsports.db.Sport( name=name, players_per_team=players_per_team ) settings = dict( template_path=os.path.join( os.path.dirname(__file__), "templates"), static_path=os.path.join(os.path.dirname(__file__), "static"), gzip=True, cookie_secret=(cookie_secret if cookie_secret else uuid.uuid4().hex), app_config=app_config, login_url="/api/auth/playerlogin" ) # Create server http_server = tornado.httpserver.HTTPServer( Application( routes=get_routes(wlsports.api), settings=settings, db_conn=wlsports.db, ) ) # Bind to port http_server.listen(port) # Register signal handlers for quitting signal.signal(signal.SIGTERM, sig_handler) signal.signal(signal.SIGINT, sig_handler) # Start IO loop tornado.ioloop.IOLoop.instance().start() logging.info("Exit...")
self.queue.flush() if __name__ == '__main__': parser = argparse.ArgumentParser(description="RedSparrow - Command Line Interface") parser.add_argument("--port", action="store", help="listen port", default=8000) parser.add_argument("--config", action="store", help="config file", default='./config/config.yml') args = parser.parse_args() logging.basicConfig(level=logging.INFO) logging.info('RedSparrow listen on %s config file %s' % (args.port, args.config)) config.load(args.config) routes = get_routes(RedSparrowApi) zmq_methods = get_methods_zmq(ZMQMethods) methods_doc_gen(zmq_methods) logging.info("ZMQ Methods\n======\n\n" + json.dumps( [(zmq_m['name'], repr(zmq_m['class'])) for zmq_m in zmq_methods], indent=2) ) logging.info("Routes\n======\n\n" + json.dumps( [(url, repr(rh)) for url, rh in routes], indent=2) ) db.bind('mysql', user=config['database']['user'], passwd=config['database']['password'], host=config['database']['host'], db=config['database']['database']) db.generate_mapping(check_tables=True, create_tables=True)
@author: Dani """ import tornado.ioloop from tornado_json.routes import get_routes from tornado_json.application import Application from google.protobuf import timestamp_pb2 from gcloud import storage import OFWorker PICKLE_BUCKET = 'pickles-python' if __name__ == '__main__': client = storage.Client() for filename in ['age_classifier.pkl', 'gender_classifier.pkl']: cblob = client.get_bucket(PICKLE_BUCKET).get_blob(filename) fp = open(filename, 'wb') cblob.download_to_file(fp) fp.close() routes = get_routes(OFWorker) application = Application(routes=routes, settings={}) application.listen(8889) tornado.ioloop.IOLoop.instance().start()
description="RedSparrow - Command Line Interface") parser.add_argument("--port", action="store", help="listen port", default=8000) parser.add_argument("--config", action="store", help="config file", default='./config/config.yml') args = parser.parse_args() logging.basicConfig(level=logging.INFO) logging.info('RedSparrow listen on %s config file %s' % (args.port, args.config)) config.load(args.config) routes = get_routes(RedSparrowApi) zmq_methods = get_methods_zmq(ZMQMethods) methods_doc_gen(zmq_methods) logging.info("ZMQ Methods\n======\n\n" + json.dumps([(zmq_m['name'], repr(zmq_m['class'])) for zmq_m in zmq_methods], indent=2)) logging.info("Routes\n======\n\n" + json.dumps([(url, repr(rh)) for url, rh in routes], indent=2)) db.bind('mysql', user=config['database']['user'], passwd=config['database']['password'], host=config['database']['host'], db=config['database']['database'])
def main(): routes = get_routes(helloworld) application = Application(routes=routes, settings={}) application.listen(8889) tornado.ioloop.IOLoop.instance().start()
def test__get_api_docs(): relative_dir = os.path.abspath(os.path.dirname(__file__)) filepath = os.path.join(relative_dir, "helloworld_API_documentation.md") HELLOWORLD_DOC = open(filepath).read() assert get_api_docs(get_routes(helloworld)) == HELLOWORLD_DOC
import logging.config import sys # Args port = sys.argv[1] # Initializing if __name__ == "__main__": # Logs logging.config.dictConfig(settings.LOGGING) # Routes routes = [] for module in settings.REST_MODULES: routes += get_routes(__import__(module)) # DB db = databases.DB().get_instance() # App app = Application(routes, db=db, settings={ 'config': utils.list2dict(db.query(Config).all()), 'tunnel': utils.get_tunnel_map(db), 'auth': utils.get_auth_map(db), 'auth_la': utils.get_auth_la_map(db), 'prebilling': utils.get_prebilling_map(db), } ) # Start tornado with multiple processes
def main(pargs): global redis if pargs.production: serverConf = configobj.ConfigObj('production.ini') else: serverConf = configobj.ConfigObj('develop.ini') routes = [ (r"/auth/login", FacebookGraphLoginHandler), (r"/", HomeHandler), (r"/referral/([^/]+)", ReferralHandler), (r"/r/([^/]+)", ReferralHandler), (r'/(favicon.ico)', StaticFileHandler, { "path": "./static/" }), ] for api in [game, tips, user, referral, prizes]: routes.extend(get_routes(api)) if pargs.admin: routes.extend(get_routes(admin)) routes.extend(get_routes(box)) from encontact import UserDataHandler routes.extend([ (r"/admin/encontact?/", UserDataHandler), ]) pprint(routes, indent=4) mailer = Mail(aws_access_key_id=serverConf['ses']['acceskeyid'], aws_secret_access_key=serverConf['ses']['secretacceskeyid'], region=serverConf['ses']['region'], sender=serverConf['ses']['sender'], template=serverConf['ses']['templates']) if pargs.production: dyn = DynamoDBConnection.connect( region=serverConf['dynamo']['region'], access_key=serverConf['dynamo']['acceskeyid'], secret_key=serverConf['dynamo']['secretacceskeyid']) session_settings = dict( driver="redis", force_persistence=True, cache_driver=True, driver_settings=dict( host=serverConf['redis']['host'], port=int(serverConf['redis']['port']), db=int(serverConf['redis']['db']), max_connections=1024, ), ) pool = ConnectionPool(max_connections=2, host=serverConf['redis']['host'], port=int(serverConf['redis']['port']), db=int(serverConf['redis']['db']) + 1) pool2 = ConnectionPool(max_connections=2, host=serverConf['redis']['host'], port=int(serverConf['redis']['port']), db=int(serverConf['redis']['db'])) else: dyn = DynamoDBConnection.connect(region='sp-east', host='127.0.0.1', port=8000, is_secure=False, access_key='asdas', secret_key='123ads') session_settings = dict( driver="redis", force_persistence=True, cache_driver=True, driver_settings=dict( host='localhost', port=6379, db=0, max_connections=1024, ), ) pool = ConnectionPool(max_connections=2, host='localhost', port=6379, db=1) pool2 = ConnectionPool(max_connections=2, host='localhost', port=6379, db=0) redis = Redis(connection_pool=pool) redis2 = Redis(connection_pool=pool2) engine = Engine(dynamo=dyn) log = logging.getLogger(__name__) a = logging.basicConfig( level=logging.INFO, format= '[ %(asctime)s ][ %(levelname)s ][ %(filename)20s:%(lineno)4s - %(funcName)20s() ] %(message)s', datefmt='%m-%d %H:%M', filename='log/nextgame.log', filemode='a') log.addHandler(a) settings = { "debug": False, 'xsrf_cookies': False, 'serverConfig': serverConf, 'instance': serverConf.get('instance'), 'engine': engine, 'facebook_api_key': serverConf['facebook']['key'], 'facebook_secret': serverConf['facebook']['secret'], 'session': session_settings, 'template_path': serverConf['ses']['templates'], "login_url": "/auth/login/", "cookie_secret": 'sopadeletrinhas123', "mailer": mailer, "production": False } if (pargs.debug): # log.setLevel(logging.DEBUG) log.debug('DEBUGGING LOG') settings['debug'] = True app = Application(routes=routes, settings=settings, db_conn={ 'ping': redis, 'session': redis2 }) if pargs.provision: game.models.create_schemas(engine) tips.models.create_schemas(engine) referral.models.create_schemas(engine) if (pargs.production): print('Server Production Starting') server = tornado.httpserver.HTTPServer(app) server.bind(serverConf['tornado']['port']) server.start(int(serverConf['tornado']['instances'])) tornado.ioloop.IOLoop.configure(TornadoUvloop) else: print('Server Develop Starting') app.listen(serverConf['tornado']['port']) tornado.ioloop.IOLoop.configure(TornadoUvloop) tornado.ioloop.IOLoop.current().start()
def main(): routes = get_routes(handlers) application = Application(routes=routes, settings=settings, db_conn=db) application.listen(options.port) tornado.ioloop.IOLoop.instance().start()