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. 在 Ubuntu 中安装 MySQL 指南

    安装MySQL 在Ubuntu上可以使用Ubuntu Software Center或者apt命令来安装MySQL,两种方式都十分方便. 1. 使用Ubuntu Software Center:打开U ...

  2. 来数一数XML解析成为Dataset数据

    最近在看一些接口,所以目标就是写接口啦,但是我想说的是公司的业务还不曾了解,所以自己先来做一个小小的demo练习吧,主要知道需要和xml有关系的,但是之前从来没有接触过解析xml文件的,在玩撒谎能够搜 ...

  3. EF的学习

    今天学习了ORM中的Entity FrearmeWork框架,其实之前看到orm框架,感觉好高大上啊,还没准备去了解它那,今天我们就学习了这个,其实Entity FrearmeWork框架和Nhibe ...

  4. PHP文件包含漏洞攻防实战

    本文对PHP文件包含漏洞的形成.利用技巧及防范进行了详细分析,并通过一个真实案例演示了如何利用PHP文件包含漏洞对目标网站进行渗透测试,最终成功获取到网站的WebShell. PHP是一种非常流行的W ...

  5. Dropbox 在 Ubuntu 上需要认证授权的问题

    在 Ubuntu 上,通过 Ubuntu软件中心 搜索下载安装了 Dropbox . 运行时,弹出如下图的提示. 输入密码,点击 授权 后,没有出现 Dropbox 的运行界面. 再次点击运行,仍会出 ...

  6. HTTP协议剖析 (附HttpWatch工具监控网络请求)

    工具:HttpWatch Prov7.2.13破解版(带正版key) HTTP协议概述   思考2个要点: 第一:浏览器和服务器是通过什么连接的 第二:这种连接方式是怎么实现的   通过Interne ...

  7. import 与 from…import 的区别

    首先你要了解 import 与 from…import 的区别. import 模块:导入一个模块:注:相当于导入的是一个文件夹,是个相对路径. from…import:导入了一个模块中的一个函数:注 ...

  8. MySQL知识小结

    MySQL的知识面试中还是经常被问到的,简单的使用似乎无法达到面试官的要求,很多问题会关于Mysql存储引擎,所以这里还是需要系统学习一下Mysql的一些知识,面试过程中游刃有余. MySQL体系结构 ...

  9. tornado 数据库操作

    tornado是python的web框架,web程序开发中数据库操作是必须的. 安装: tornado的官方文档中提供的说明比较少,而且提供的模块中未找到数据库方面的模块,难道没有针对数据库操作进行封 ...

  10. C# 根据域名获取IP地址

    今天做海康微视视频接口的时候要用到硬盘录像机的IP地址.端口号.用户名和密码. 但是发现客户IP地址是动态获取的,经常变化. 所以需要根据域名解析出IP. 代码如下 //判断输入的是否是IP Rege ...