0

Can Not Understand The Flow Of This Coroutines Program Any One Help Me to Understand This Code

https://code.sololearn.com/cu9h2x4gz44b/?ref=app

29th Mar 2020, 5:51 AM
Devang H Baroliya
Devang H Baroliya - avatar
2 Respuestas
+ 1
Lines 42-45 make it so you have new coroutines that wait at the line `token = (yield)` for input. `producer` then splits the string, and sends the first token to pattern_filter, we hop from line 11 to line 23. pattern_filter then sends the token to print_token, we hop from line 25 to line 37. print_token prints the token on line 38 and loops, then waits on line 37 for more input. pattern_filter does the same on line 23. producer sends the next token and the whole thing starts over.
29th Mar 2020, 11:27 AM
Schindlabua
Schindlabua - avatar
+ 2
That is unless producer runs out of words, which is when `token = (yield)` will throw an exception and we exit the `while True` loops.
29th Mar 2020, 11:28 AM
Schindlabua
Schindlabua - avatar