Tornado 4.3b1,支持 async/await 关键字

2015-10-19 18:04:00 +08:00
 janxin
Highlights
---

* The new async/await keywords in Python 3.5 are supported. In most cases,
```async def``` can be used in place of the ``@gen.coroutine`` decorator.
Inside a function defined with ``async def``, use ``await`` instead of
``yield`` to wait on an asynchronous operation. Coroutines defined with
async/await will be faster than those defined with ``@gen.coroutine`` and
``yield``, but do not support some features including `.Callback`/`.Wait` or
the ability to yield a Twisted ``Deferred``.
* The async/await keywords are also available when compiling with Cython in
older versions of Python.

Deprecation notice
---

* This will be the last release of Tornado to support Python 2.6 or 3.2.
Note that PyPy3 will continue to be supported even though it implements
a mix of Python 3.2 and 3.3 features.

更多的请看:[http://www.tornadoweb.org/en/latest/releases/next.html]( http://www.tornadoweb.org/en/latest/releases/next.html)

不知道 asyncio 的库是不是可以直接用在 Tornado 上面了,如果可以我就升到 3.5 了....
2477 次点击
所在节点    Python
10 条回复
aliuwr
2015-10-19 18:17:52 +08:00
Python 3.5 感觉好远
janxin
2015-10-19 19:46:38 +08:00
@aliuwr 之前一直停留在 2.7 ,之前觉得 yield from 这个实在是不优雅,不过有 async/await 要好很多了
echo1937
2015-10-19 19:51:20 +08:00
还在 3.43,有先行者吗?
chengzhoukun
2015-10-19 19:56:18 +08:00
JS 也快支持了
Feiox
2015-10-19 20:07:25 +08:00
@echo1937 我们已经开始实验 3.5 了,因为现在的项目使用了一些 asyncio 。其实对我们更有吸引力的是 typing 这个标准库 ~ 已经准备大刀阔斧的迁移了。
话说, PHP7 Node 都配备了 JIT , CPython 何时来拯救我们 ~
echo1937
2015-10-19 20:09:53 +08:00
@Feiox 请问下,你们是什么项目?
Feiox
2015-10-19 20:15:26 +08:00
@echo1937 一个不太要求速度的爬虫,一些业务逻辑,还有几个内部使用的 Py 库(处理抽象业务逻辑的)。主要还是和 Web 业务、文本数据的处理有关。
PythonAnswer
2015-10-19 20:49:06 +08:00
感觉 tornado 又要来一波爆发了.
django 之类的不知道什么时候才能引入 async await
fy
2015-10-19 22:14:33 +08:00
3.4 的时候就已经转了 py3 ,感觉良好。

顺便再厚着脸皮推一下自己的 Tornado 项目模板: https://github.com/fy0/fpage
janxin
2015-10-19 22:53:53 +08:00
@PythonAnswer django 本来就是同步模型,跟异步关系应该不大,即使引入范围也不会大的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/229293

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX