Hi.I'm trying to make sans-io library.
- 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).
- 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 responseresponse = yield Request(...) # actually login
yield Nonedef act(generator):response = Nonewhile True:request = generator.send(response)if request is None:return responseresponse = # do ioact(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?