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.

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
AttributeError: module 'tornado.web' has no attribute 'asynchronous'

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?

1 Answers

Ben Darnell On

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).

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.