Skip to content
libcst transformer that replaces tornado's legacy @gen.coroutine syntax with python3.5+ native async/await
Python JavaScript HTML CSS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows
api
tests
tornado_async_transformer
.gitignore
LICENSE
README.md
index.html
mypy.ini
pyproject.toml Setup playground for demo'ing transformer (#3) Sep 6, 2019
requirements.txt
script.js
setup.cfg
setup.py
style.css

README.md

Tornado Async Transformer

A libcst transformer for updating tornado @gen.coroutine syntax to python3.5+ native async/await.

Check out the demo.

Usage

You can either:

  • Add tornado_async_transformer.TornadoAsyncTransformer to your existing libcst codemod.
  • Or run python -m tornado_async_transformer.tool my_project/ from the commandline.

Example

 """
 A simple coroutine.
 """
 from tornado import gen


-@gen.coroutine
-def call_api():
-    response = yield fetch()
+async def call_api():
+    response = await fetch()
     if response.status != 200:
         raise BadStatusError()
-    raise gen.Return(response.data)
+    return response.data
You can’t perform that action at this time.