Fourth example from PEP 342

Léo El Amri leo at superlel.me
Fri Jan 19 16:50:22 EST 2018


Hello list,

I am currently trying to learn co-routine/asynchronous mechanisms in
Python. I read the PEP 342, but I stumble on the fourth example.
I don't understand what the lines "data = yield nonblocking_read(sock)"
in echo_handler() and "connected_socket = yield
nonblocking_accept(sock)" in listen_on() are trying to do.

For example, can someone explain me how the returned value in the line
"connected_socket = yield nonblocking_accept(sock)" can be used on the
next line ("trampoline.add(handler(connected_socket))") ? To me, it
looks like the returned value is lost in the Trampoline, when resume()
gets the returned value of the yield expression.

Léo



More information about the Python-list mailing list