Comment

Comment by shanemhansen

Great article. I had the misfortune of writing a bunch of twisted code over a decade ago and I wanted to remind the author that twisted has a feature called "inline callbacks" that allow you to use yield. https://twisted.org/documents/16.4.1/core/howto/defer-intro....

So twisted code can actually look like:

    @inlineCallbacks
    def doIt():
        responseBody = yield makeRequest("GET", "/users")
        returnValue(json.loads(responseBody))
iirc `returnValue` throws an exception of a specific type. It's ugly, but it's also the logical implementation of async on top of yield/generators.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton