|
|
|
|
|
by johnsoft
4841 days ago
|
|
Just to check if I'm understanding the presentation right, will the implementation involve compiler magic to turn this: @coroutine
def getresp():
s = socket()
yield from loop.sock_connect(s, host, port)
yield from loop.sock_sendall(s, b'xyzzy')
data = yield from loop.sock_recv(s, 100)
# ...
into this, similar to how C# does it? (let's pretend multi-line lambdas exist for a minute) def getresp():
s = socket()
loop.sock_connect(s, host, port).add_done_callback(lambda:
loop.sock_sendall(s, b'xyzzy').add_done_callback(lambda:
data = loop.sock_recv(s, 100).add_done_callback(lambda:
# ...
)
)
)
Or will the `yield from`s bubble up all the way to the event loop and avoid the need for that? |
|
It is Eventlet and Gevent have that magic. Here is how that looks:
Compare that to any of the above. This is what is thrown away in favor of 'yield from' and @coroutine mess coupled with a completely parallel set of IO libraries.