coroutines
ast
nomail at com.invalid
Thu Aug 3 03:53:43 EDT 2017
Hello
Here a code for a simple demultiplexer coroutine
def demultiplexer(target1, target2):
while True:
data = yield
target1.send(data)
target2.send(data)
When data is sent to target1, what Cpython do
immediately after ?
1- Go on execute demultiplexer, so send a data
to target2 then pause demultiplexer when it reach
line data=yied, then execute coroutine target1, then
execute coroutine target2
or
2- Go and execute target1 coroutine, then resume
demultiplexer, so send a data to target2, go to target2,
then resume demultiplexer and stops
More information about the Python-list
mailing list