4 ms·
I see a few advantages: 1. Requires much less modification to existing code than a callback style. 2. Code written in the sequential style is shorter, easier
by csytan 16y ago
I see a few advantages:
1. Requires much less modification to existing code than a callback style.
2. Code written in the sequential style is shorter, easier to understand, and just as explicit.
Edit, also from his article:
"""By decorating your functions with @tasklet and writing yield in front of blocking operations, you get the benefits of concurrent asynchronous I/O without the drawbacks of callback functions. Here's a blog comparing the two styles in the context of Twisted. The Monocle framework also promotes this style, and their introduction provides a good explanation of why coroutines are better than callback (scroll down to "The Big Idea")."""
Links:
http://blog.mekk.waw.pl/archives/14-Twisted-inlineCallbacks-and-deferredGenerator.html http://blog.mekk.waw.pl/archives/14-Twisted-inlineCallbacks-...
https://github.com/saucelabs/monocle#readme https://github.com/saucelabs/monocle#readme