Alex, I don't get why generators are bad for sans io? For me It's just simple state holder. Some things need multiply steps for making one high-level action. And in this case you can make class, which will hold state between calls and switch with "ugly" if/elif/elif/.../elif/else or you can use generator, so protocol code will have readable flow and looks like it is with io. Probably I missed something about generators?
On Mon, Oct 24, 2016 at 8:08 PM, MultiSosnooley . <multisosnoo...@gmail.com> wrote: > Hi. > > I'm trying to make sans-io library. > > 1. Protocol works over http, so I've just passing Request object with > method, url, data, etc. fields to user and receive Response object (json in > this case). > 2. I'm using generators for simplification of holding state of > multirequest actions. Something like this: > > def login(): > > response = yield Request(...) # check server state > # update state with response > response = yield Request(...) # actually login > yield None > > def act(generator): > response = None > while True: > request = generator.send(response) > if request is None: > return response > response = # do io > > act(login()) > > This solve problem multistep actions. The downside is that all your > protocol functions, event if they have only one request and don't need > response at all, must be generators. > > Is it ok to send just abstract Request and receive abstract Response (not > just bytes)? > Is there a better solution for multirequest actions? >
_______________________________________________ Async-sig mailing list Async-sig@python.org https://mail.python.org/mailman/listinfo/async-sig Code of Conduct: https://www.python.org/psf/codeofconduct/