tornado 多进程模式
来源:互联网 发布:软件开发 需求文档 编辑:程序博客网 时间:2024/05/16 22:22
https://www.douban.com/note/217901726/
官方文档的helloworld实例中的启动方法:
if __name__ == "__main__":
application.listen(8888) # listen is a shortcut for bind and start ,这点看httpserver.py可以得知
tornado.ioloop.IOLoop.instance().start()
并且在listen中,将tornado启动为单进程模型。
所以要启动为多进程模型的方法为:摒弃listen方法
http_server = tornado.httpserver.HTTPServer(application)
http_server.bind(options.port, options.host)
http_server.start(num_processes=0) # tornado将按照cpu核数来fork进程
tornado.ioloop.IOLoop.instance().start()
需要注意的一点是,要关掉debug模式,否则:
[E 110521 11:26:53 httpserver:229] Cannot run in multiple processes: IOLoop instance has already been initialized. You cannot call IOLoop.instance() before calling start()
原因是,autoreload.py已经在http_server.start()之前就初始化了IOLoop,这个在httpserver.py中的class HTTPServer()和def start()的doc string中已经解释了。
0 0
- tornado 多进程模式
- Tornado 多进程模式
- Tornado 多进程 & 异步
- Tornado 多进程实现分析
- Tornado 多进程实现分析
- Tornado多进程方式log切分错误的解决方案
- Tornado Web服务器多进程启动的2个方法
- Tornado框架02-创建服务器与多进程
- tornado thread 任务处理模式
- tornado singleton单例模式
- 21.番外篇:Tornado的多进程管理分析---process.py代码解读
- tornado
- Tornado
- Tornado
- tornado
- Tornado
- tornado
- tornado
- Windows 上 Assimp(Open Asset Import Library) 源码的编译 及 Samples 的编译运行
- 阿里2017笔试(2)
- HDOJ 5763 Another Meaning
- C++读书笔记1:C语言基础知识
- Math对象方法
- tornado 多进程模式
- USB 3.0 对无线鼠标的干扰问题
- hduoj1879
- 【Python数据挖掘课程】五.线性回归知识及预测糖尿病实例
- Constructor详解
- Codeforces 722C - Destroying Array By Assassin
- c3p0-数据库连接池
- 【共享内存】共享内存
- strassen方法求任意行列数的矩阵乘法