The terms asynchronous and non-blocking are closely related and are often used interchangeably, but they are not quite the

same thing.

Blocking

A function blocks when it waits for something to happen before returning. A function may block for many reasons: network I/O,

disk I/O, mutexes, etc. In fact, every function blocks, at least a little bit, while it is running and using the CPU (for an extreme

example that demonstrates why CPU blocking must be taken as seriously as other kinds of blocking, consider password hashing

functions like bcrypt, which by design use hundreds of milliseconds of CPU time, far more than a typical network or disk access).

A function can be blocking in some respects and non-blocking in others. For example,tornado.httpclient in the default

configuration blocks on DNS resolution but not on other network access (to mitigate this use ThreadedResolver or a

tornado.curl_httpclient with a properly-configured build of libcurl). In the context of Tornado we generally talk about

blocking in the context of network I/O, although all kinds of blocking are to be minimized.

Asynchronous

An asynchronous function returns before it is finished, and generally causes some work to happen in the background before triggering

some future action in the application (as opposed to normal synchronous functions, which do everything they are going to do before

returning). There are many styles of asynchronous interfaces:

  • Callback argument
  • Return a placeholder (FuturePromiseDeferred)
  • Deliver to a queue
  • Callback registry (e.g. POSIX signals)

Regardless of which type of interface is used, asynchronous functions by definition interact differently with their callers; there is no free

way to make a synchronous function asynchronous in a way that is transparent to its callers (systems like gevent use lightweight threads

to offer performance comparable to asynchronous systems, but they do not actually make things asynchronous).

参考:

同步、异步、阻塞、非阻塞

tornado : 异步、非阻塞的更多相关文章

  1. Tornado异步非阻塞的使用以及原理

    Tornado 和现在的主流 Web 服务器框架(包括大多数 Python 的框架)有着明显的区别:它是非阻塞式服务器,而且速度相当快.得利于其 非阻塞的方式和对 epoll 的运用,Tornado ...

  2. Python web框架 Tornado异步非阻塞

    Python web框架 Tornado异步非阻塞   异步非阻塞 阻塞式:(适用于所有框架,Django,Flask,Tornado,Bottle) 一个请求到来未处理完成,后续一直等待 解决方案: ...

  3. Tornado 异步非阻塞

    1 装饰器 + Future 从而实现Tornado的异步非阻塞 class AsyncHandler(tornado.web.RequestHandler): @gen.coroutine def ...

  4. Python3的原生协程(Async/Await)和Tornado异步非阻塞

    原文转载自「刘悦的技术博客」https://v3u.cn/a_id_113 我们知道在程序在执行 IO 密集型任务的时候,程序会因为等待 IO 而阻塞,而协程作为一种用户态的轻量级线程,可以帮我们解决 ...

  5. Tornado的异步非阻塞

    阻塞和非阻塞Web框架 只有Tornado和Node.js是异步非阻塞的,其他所有的web框架都是阻塞式的. Tornado阻塞和非阻塞两种模式都支持. 阻塞式: 代表:Django.Flask.To ...

  6. 150行代码搭建异步非阻塞Web框架

    最近看Tornado源码给了我不少启发,心血来潮决定自己试着只用python标准库来实现一个异步非阻塞web框架.花了点时间感觉还可以,一百多行的代码已经可以撑起一个极简框架了. 一.准备工作 需要的 ...

  7. 使用tornado让你的请求异步非阻塞

    http://www.dongwm.com/archives/shi-yong-tornadorang-ni-de-qing-qiu-yi-bu-fei-zu-sai/?utm_source=tuic ...

  8. 异步非阻塞IO的Python Web框架--Tornado

    Tornado的全称是Torado Web Server,从名字上就可知它可用作Web服务器,但同时它也是一个Python Web的开发框架.最初是在FriendFeed公司的网站上使用,FaceBo ...

  9. 03: 自定义异步非阻塞tornado框架

    目录:Tornado其他篇 01: tornado基础篇 02: tornado进阶篇 03: 自定义异步非阻塞tornado框架 04: 打开tornado源码剖析处理过程 目录: 1.1 源码 1 ...

  10. tornado 之 异步非阻塞

    异步非阻塞 1.基本使用 装饰器 + Future 从而实现Tornado的异步非阻塞 import tornado.web import tornado.ioloop from tornado im ...

随机推荐

  1. 先安装VS2017再安装VS2015遇到的CMake问题

    先安装了VS2017,后来有需求安装VS2015,安装VS2015的时候遇到下图问题,但是控制面板里面看不到Microsoft Visual C++ 2015 Redistributable的项目 我 ...

  2. MyEclipse 10 下在线安装插件

    昨天不知道怎么就删除了电脑中的eclipse 我x,还原不回来了. 今天就安装了最新版本的myeclipse10,大家都知道,MyEclipse 中有一个烦人的 Software and Worksp ...

  3. [转载]ASP.NET伪静态页面的实现和伪静态在IIS7.0中的配置

    ASP.NET伪静态 UrlRewrite(Url重写) 实现和配置 最近在写一个CMS的内容管理系统,需要用到一个伪静态方面的方法,在网上找了一下这方面的资料,现将这方面的资源记录一下. 本机环境: ...

  4. python基础---->python的使用(四)

    这里记录一下python关于网络的一些基础知识.不知为何,恰如其分的话总是姗姗来迟,错过最恰当的时机. python中的网络编程 一.socket模板创建一个 TCP 服务器 import socke ...

  5. 笔者使用macOS的一些经验点滴记录1

    (1) 输入法快捷键 ctrl+shift+p  拼音 ctrl+shift+W  五笔型 按CapsLock可以在英文与指定中文输入法间进行切换 (2) 定时关机 sudo shutdown -h ...

  6. python中字符串(str)的常用处理方法

    str='python String function' 生成字符串变量str='python String function' 字符串长度获取:len(str)例:print '%s length= ...

  7. sencha touch list 批量选择扩展(2013-7-29)

    扩展js代码 /* *list多选扩展 */ Ext.define('ux.SimpleList', { alternateClassName: 'simpleList', extend: 'Ext. ...

  8. 完全卸载Oracle数据库软件

    软件环境: 1.Windows xp+ORACLE 8.1.7 2.ORACLE安装路径为:C:\ORACLE 实现方法: 1. 开始->设置->控制面板->管理工具->服务 ...

  9. 使用spring提供的ReflectionUtils简化项目中反射代码的复杂性

    在项目中有时候我们会使用到反射的功能,如果使用最原始的方法来开发反射的功能的话肯能会比较复杂,需要处理一大堆异常以及访问权限等问题.spring中提供了ReflectionUtils 这个反射的工具类 ...

  10. [NHibernate] Guid 作主键速度超慢的背后

    http://blog.csdn.net/educast/article/details/6602353 最近遇到了一个让人抓狂的性能问题.生产环境里有一张表的数据量目前达到了 70 万条.结果发现无 ...