I personally recommend against using generators in any form in a sans-io
protocol implementation. Are you absolutely sure that you need them? Do
you understand what the responsibilities of a sans-io protocol are?
24.10.2016, 20:08, MultiSosnooley . kirjoitti:
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/
_______________________________________________
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/