本文整理汇总了Python中tornado.web.Application.clients方法的典型用法代码示例。如果您正苦于以下问题:Python Application.clients方法的具体用法?Python Application.clients怎么用?Python Application.clients使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.web.Application
的用法示例。
在下文中一共展示了Application.clients方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_server
# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import clients [as 别名]
def run_server(args):
ioloop = IOLoop.current()
path = os.path.dirname(os.path.realpath(__file__))
settings = {
'template_path': path + os.sep + 'templates',
'port': args.port,
}
app = Application([
url(r"/ws", WsHandler),
url(r"/", TraceHandler),
],
**settings
)
app.listen(args.port)
app.clients = {}
ioloop.start()
示例2: main
# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import clients [as 别名]
def main():
global config, logger, msg_queue, app
logger = logging.getLogger('hedwig.nest')
msg_queue = Queue(maxsize=2)
app = Application([
(r"/", MainHandler),
])
config = {}
try:
opts, _ = getopt.gnu_getopt(sys.argv[1:], "vc:", ["version", "config"])
except getopt.GetoptError as _:
print("Usage: hedwig -c config")
sys.exit(2)
configFile = './nest.conf.yml'
for opt, arg in opts:
if opt == '-v':
print(__version__)
sys.exit()
elif opt == '-c' or opt == '--config':
configFile = arg
break
with open(configFile, 'r') as f:
config = yaml.load(f)
# 设定 Logging
logging.basicConfig(format='[%(levelname)s] %(message)s')
if config.get('debug', False):
logger.setLevel(logging.DEBUG)
else:
logger.setLevel(logging.INFO)
app.clients = config.get('clients', {})
listen_config = config.get('listen', { 'host': '0.0.0.0', 'port': 80 })
app.listen(port=listen_config['port'], address=listen_config['host'])
logger.info('Hedwig Nest is on {host}:{port}...'.format(
host=listen_config['host'], port=listen_config['port']))
IOLoop.current().spawn_callback(message_consumer)
IOLoop.current().start()