我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用tornado.ioloop.IOLoop.configure()。
def main(): parse_command_line() if options.ioloop: IOLoop.configure(options.ioloop) for i in xrange(options.num_runs): run()
def configure_ioloop(): kwargs = {} if options.ioloop_time_monotonic: from tornado.platform.auto import monotonic_time if monotonic_time is None: raise RuntimeError("monotonic clock not found") kwargs['time_func'] = monotonic_time if options.ioloop or kwargs: IOLoop.configure(options.ioloop, **kwargs)
def get_new_ioloop(self): """Override the creation of the IOLoop mimicking that of application. The result needs to be a Tornado IOLoop instance, we first configure the asyncio loop and then call IOLoop configure to use it. """ if sys.platform == 'linux': selector = selectors.SelectSelector() loop = asyncio.SelectorEventLoop(selector) asyncio.set_event_loop(loop) IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop') return IOLoop.current()