Following the Tornado documentation, I found that a common way to provide asynchronous behavior is to use event loop and callback functions. But using callbacks is syntactically complicated and confusing. Therefore, tornado developers came up with the use of decorators (just like a bulb, cherry, etc.).
- When you follow the Tornado source code, you will see the
gen.py module under which they define the coroutine decorator. This is a truly elegant way to provide concurrency in a tornado. raise designed to handle exceptions. I find this pretty simple, as it just returns except gen.Return .- Using Tornado
generators easy to use.
source share