刘荣星的博客

  • 留言
  • About
一个关注Linux/BSD运维等相关知识的博客
  1. 首页
  2. Python
  3. Tornado
  4. 正文

learning tornado 101

2015-10-24 12572点热度 0人点赞 0条评论

在 Ubuntu 14.04.1 LTS 桌面系统里安装了 pycharm-4.5.4,Linux 下的 pycharm 是通过 java 来运行的,所以需要安装 Java jdk.
安装命令很简单

sudo apt-get install openjdk-7-jdk

Tornado 是 FriendFeed 使用的可扩展的非阻塞式 web 服务器及其相关工具的开源版本。这个 Web 框架看起来有些像web.py 或者 Google 的 webapp,不过为了能有效利用非阻塞式服务器环境,这个 Web 框架还包含了一些相关的有用工具 和优化。

Tornado 和现在的主流 Web 服务器框架(包括大多数 Python 的框架)有着明显的区别:它是非阻塞式服务器,而且速度相当快。得利于其 非阻塞的方式和对 epoll 的运用,Tornado 每秒可以处理数以千计的连接,这意味着对于实时 Web 服务来说,Tornado 是一个理想的 Web 框架。我们开发这个 Web 服务器的主要目的就是为了处理 FriendFeed 的实时功能 ——在 FriendFeed 的应用里每一个活动用户都会保持着一个服务器连接。(关于如何扩容 服务器,以处理数以千计的客户端的连接的问题,请参阅 C10K problem。)

请参见 Tornado 文档 或 Tornado 原文文档(镜像)以详细了解该 Web 框架。

Tornado 官网:http://www.tornadoweb.org/en/stable/

Tornado Github

下面是安装的最新版 Tornado 4.2.1,本应该下载 .tar.gz 包来手动安装,及其它的基础包的,方便以后服务器上安装统一的环境。
但是这次使用的 pip 安装,安装命令如下:

$ sudo pip install tornado
Downloading/unpacking tornado
  Downloading tornado-4.2.1.tar.gz (434kB): 434kB downloaded
  Running setup.py (path:/tmp/pip_build_root/tornado/setup.py) egg_info for package tornado
    
    no previously-included directories found matching 'docs/build'
    warning: no files found matching 'tornado/test/README'
Downloading/unpacking backports.ssl-match-hostname (from tornado)
  Downloading backports.ssl_match_hostname-3.4.0.2.tar.gz
  Running setup.py (path:/tmp/pip_build_root/backports.ssl-match-hostname/setup.py) egg_info for package backports.ssl-match-hostname
    
Downloading/unpacking certifi (from tornado)
  Downloading certifi-2015.9.6.2-py2.py3-none-any.whl (371kB): 371kB downloaded
Installing collected packages: tornado, backports.ssl-match-hostname, certifi
  Running setup.py install for tornado
    building 'tornado.speedups' extension
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c tornado/speedups.c -o build/temp.linux-x86_64-2.7/tornado/speedups.o
    tornado/speedups.c:2:20: fatal error: Python.h: 没有那个文件或目录
     #include <Python.h>
                        ^
    compilation terminated.
    /tmp/pip_build_root/tornado/setup.py:94: UserWarning:
    ********************************************************************
    WARNING: The tornado.speedups extension module could not
    be compiled. No C extensions are essential for Tornado to run,
    although they do result in significant speed improvements for
    websockets.
    The output above this warning shows how the compilation failed.
    
    Here are some hints for popular operating systems:
    
    If you are seeing this message on Linux you probably need to
    install GCC and/or the Python development package for your
    version of Python.
    
    Debian and Ubuntu users should issue the following command:
    
        $ sudo apt-get install build-essential python-dev
    
    RedHat, CentOS, and Fedora users should issue the following command:
    
        $ sudo yum install gcc python-devel
    
    If you are seeing this message on OSX please read the documentation
    here:
    
    http://api.mongodb.org/python/current/installation.html#osx
    ********************************************************************
    
      "The output above "
    command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
    no previously-included directories found matching 'docs/build'
    warning: no files found matching 'tornado/test/README'
  Running setup.py install for backports.ssl-match-hostname
    
Successfully installed tornado backports.ssl-match-hostname certifi
Cleaning up...




$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tornado
>>> tornado.version
'4.2.1'
>>> 

OK,开工!

标签: python tornado
最后更新:2015-10-24

JavasBoy

这个人很懒,什么都没留下

点赞

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

最新 热点 随机
最新 热点 随机
CentOS7 python2 安装 elasticsearch 模块 在VMWare Workstation虚拟机里使用 yubikey Gentoo Gnome 登陆界面开启触摸板轻击 python3去除emoji表情符号 记录几个内网广播包 Linux Mint 20 gnome-terminal 使用等距更纱黑体 SC字体
FreeBSD ports 使用proxychains解决下载慢问题 黑屏解决方法、微软正版验证解决方法 nVida GeForce 8500 GT DSDT驱动完善 有两个多月没更新博客了吧 mark archlinux update 分享AfterEffects-ae表达式中英对照表
分类
  • After Effects / 20篇
  • Apple / 5篇
  • Archlinux / 4篇
  • Bash / 2篇
  • Cinema 4D / 1篇
  • Docker / 1篇
  • eMule / 2篇
  • FreeBSD / 9篇
  • Gentoo / 1篇
  • Go / 2篇
  • gpg / 1篇
  • Graphics / 15篇
  • Haproxy / 1篇
  • ingress / 1篇
  • IntelliJ_IDEA / 1篇
  • java / 2篇
  • kafka / 1篇
  • Linux / 24篇
  • MySQL / 3篇
  • network / 3篇
  • Network / 4篇
  • Nginx / 5篇
  • Perl / 4篇
  • Python / 9篇
  • Python 操作符 / 1篇
  • Python 正则 / 2篇
  • rose / 1篇
  • Script / 4篇
  • Tornado / 1篇
  • Vim / 5篇
  • 学习 / 24篇
  • 电脑 / 29篇
  • 那不勒斯 / 1篇
  • 随笔 / 45篇
标签聚合
Graphics After Effects 双系统 Linux MAC AE python FreeBSD

COPYRIGHT © 2025 刘荣星的博客. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang