推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
nanbei
V2EX  ›  Python

最近在研究tornado框架,其实在很多时候,我们的网站并没有那么多的异步需求,除了技术尝鲜外,我们在什么情况下会用到异步呢?

  •  
  •   nanbei · Dec 21, 2012 · 4940 views
    This topic created in 5034 days ago, the information mentioned may be changed or developed.
    5 replies  •  1970-01-01 08:00:00 +08:00
    BigZ
        1
    BigZ  
       Dec 21, 2012
    在web系统里面基本上用不上异步

    生产环境中,如果计算特别费时,一般都用消息队列
    spritevan
        2
    spritevan  
       Dec 21, 2012
    请求第三方api
    zhangxiao
        3
    zhangxiao  
       Dec 21, 2012
    把所有不涉及response输出的操作都异步化,比如log之类的
    reorx
        4
    reorx  
       Dec 21, 2012
    @BigZ 不过也有既耗时又不能用消息队列的情况,比如对某网站申请 OAuth 认证,这个时候 @asynchronous 就很有用了。
    hit9
        5
    hit9  
       Nov 25, 2013
    - 网络IO
    - 请求分散到多个服务中的清形
    - 。。。

    总的来说是那种“需要等待的”情况,所谓并发需要异步。把排队地串行变成“逻辑上”的并行,不让程序闲着,某个任务的执行阻塞当前进程的时候,另一个任务并不依赖其执行结果的话,完全可以两个服务都去跑,不要阻塞。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1000 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 17:47 · PVG 01:47 · LAX 10:47 · JFK 13:47
    ♥ Do have faith in what you're doing.