tornado : 异步、非阻塞
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 (
Future,Promise,Deferred) - 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 : 异步、非阻塞的更多相关文章
- Tornado异步非阻塞的使用以及原理
Tornado 和现在的主流 Web 服务器框架(包括大多数 Python 的框架)有着明显的区别:它是非阻塞式服务器,而且速度相当快.得利于其 非阻塞的方式和对 epoll 的运用,Tornado ...
- Python web框架 Tornado异步非阻塞
Python web框架 Tornado异步非阻塞 异步非阻塞 阻塞式:(适用于所有框架,Django,Flask,Tornado,Bottle) 一个请求到来未处理完成,后续一直等待 解决方案: ...
- Tornado 异步非阻塞
1 装饰器 + Future 从而实现Tornado的异步非阻塞 class AsyncHandler(tornado.web.RequestHandler): @gen.coroutine def ...
- Python3的原生协程(Async/Await)和Tornado异步非阻塞
原文转载自「刘悦的技术博客」https://v3u.cn/a_id_113 我们知道在程序在执行 IO 密集型任务的时候,程序会因为等待 IO 而阻塞,而协程作为一种用户态的轻量级线程,可以帮我们解决 ...
- Tornado的异步非阻塞
阻塞和非阻塞Web框架 只有Tornado和Node.js是异步非阻塞的,其他所有的web框架都是阻塞式的. Tornado阻塞和非阻塞两种模式都支持. 阻塞式: 代表:Django.Flask.To ...
- 150行代码搭建异步非阻塞Web框架
最近看Tornado源码给了我不少启发,心血来潮决定自己试着只用python标准库来实现一个异步非阻塞web框架.花了点时间感觉还可以,一百多行的代码已经可以撑起一个极简框架了. 一.准备工作 需要的 ...
- 使用tornado让你的请求异步非阻塞
http://www.dongwm.com/archives/shi-yong-tornadorang-ni-de-qing-qiu-yi-bu-fei-zu-sai/?utm_source=tuic ...
- 异步非阻塞IO的Python Web框架--Tornado
Tornado的全称是Torado Web Server,从名字上就可知它可用作Web服务器,但同时它也是一个Python Web的开发框架.最初是在FriendFeed公司的网站上使用,FaceBo ...
- 03: 自定义异步非阻塞tornado框架
目录:Tornado其他篇 01: tornado基础篇 02: tornado进阶篇 03: 自定义异步非阻塞tornado框架 04: 打开tornado源码剖析处理过程 目录: 1.1 源码 1 ...
- tornado 之 异步非阻塞
异步非阻塞 1.基本使用 装饰器 + Future 从而实现Tornado的异步非阻塞 import tornado.web import tornado.ioloop from tornado im ...
随机推荐
- C# Serializable对象序列化的作用
http://www.cnblogs.com/linlf03/archive/2011/11/03/2234424.html 1.序列化定义:将对象转换为容易传输的格式的过程.例如,可以序列化一个对象 ...
- 在 Core Data 中存取 transformable 类型的数据
本文转载至 http://imenjoe.com/2015/04/10/CoreData-transformable-20150410/ 在开发过程中有一个需要在 Core Data 中存取 NSDi ...
- open-falcon之alarm、sender、links说明.md
alarm 功能 处理judge 产生的告警event 区分告警优先级,优先处理级别比较高的告警 为用户提供回调接口 生成告警msg 展示未恢复的告警 配置文件 { "debug" ...
- 【cs229-Lecture7】支持向量机(SVM)
SVM不错的学习资料: 百度网盘链接: http://pan.baidu.com/s/1hqw0Rnm 密码: asec blog:http://www.blogjava.net/zhenandaci ...
- Qt编写视频播放器(vlc内核)
在研究qt+vlc的过程中,就想直接做个播放器用于独立的项目,vlc还支持硬件加速,不过部分电脑硬件不支持除外.用vlc的内核写播放器就是快,直接调用api就行,逻辑处理和ui展示基本上分分钟的事情, ...
- MFC 常见问题
一 常见变量获得 CDC * cDc=GetDC(); HDC m_Screenhdc = this->GetDC()->m_hDC; // 整个窗口客户区的坐标 this->Ge ...
- Spark学习笔记--Linux安装Spark集群详解
本文主要讲解如何在Linux环境下安装Spark集群,安装之前我们需要Linux已经安装了JDK和Scala,因为Spark集群依赖这些.下面就如何安装Spark进行讲解说明. 一.安装环境 操作系统 ...
- 报错--"npm audit fix" or "npm audit"
如图: 根据提示输入 npm audit fix --force 如图: 根据提示输入: npm audit
- 持续集成环境--Tomcat热部署导致线程泄漏
一.问题由来 我们组用jenkins部署了持续集成环境,(jenkins部署war包到远程服务器的tomcat). 每次提交了代码,jenkins上一键构建,就可以自动拉取最新代码,打war包,热部署 ...
- 2018 青岛ICPC区域赛E ZOJ 4062 Plants vs. Zombie(二分答案)
Plants vs. Zombies Time Limit: 2 Seconds Memory Limit: 65536 KB BaoBao and DreamGrid are playin ...