龙卷风v6似乎已删除tornado.web.asynchronous协程.在代码中解决此问题的任何其他方法? [英] tornado v6 seems to have dropped tornado.web.asynchronous coroutine. any different way of fixing this in code?
问题描述
将torando v5.1迁移到v6.但异步协程似乎已删除.有任何修复建议吗?
Migrated torando v5.1 to v6. but asynchronous coroutine seems to have removed. Any suggestions for its fix?
Migrating the project from 2.7 to 3.6, at the same time moving tornado framework from v5.1 to v6.0.2 due to the bug suggested in this [Python code for DynamoDB query is working on v3.6 but not working in python 2.7 strackoverflow thread.
在安装v6龙卷风之后,它以以下错误中断.
After installing v6 tornado it is breaking with below error.
Python3 xxxx.py
Traceback (most recent call last):
File "XXXX.py", line 200, in <module>
class MainHandler(tornado.web.RequestHandler):
File "XXXX.py", line 201, in MainHandler
@tornado.web.asynchronous
AttributeError: module 'tornado.web' has no attribute 'asynchronous'
进入 https://github.com/mher/flower/issues/878
Come across https://github.com/mher/flower/issues/878 thread facing the same issue. is there a fix for this? or any alternative way of presenting things in code?
推荐答案
@asynchronous
处理程序在5.1中已弃用,在6.0中已删除.
The @asynchronous
handler was deprecated in 5.1 and removed in 6.0. Instead of using @asynchronous
and callbacks, you should use coroutines (using either @tornado.gen.coroutine
or async def
).
请注意,一些较旧的代码示例曾经在同一方法上同时具有@asynchronous
和@coroutine
.将@asynchronous
放在协程上没有任何作用,因此,如果您碰巧同时使用了两个装饰器,则只需删除@asynchronous
即可,而无需进行其他任何更改.
Note that a few older code examples used to have both @asynchronous
and @coroutine
on the same method. Putting @asynchronous
on a coroutine doesn't do anything, so if you happen to be using both decorators you can just remove @asynchronous
without changing anything else.
这篇关于龙卷风v6似乎已删除tornado.web.asynchronous协程.在代码中解决此问题的任何其他方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!