advanced programming techniques coroutine (coroutine (coroutine ( create coroutines waiting waiting waiting coroutine send(" "process "awaiting waiting step action coroutine send(" "process "aprocess "awaiting coroutine send(" "waiting process "aprocess " coroutine send(" "process "bprocess "aprocess " coroutine send(" "process "bprocess " ("bpendingprocess " coroutine send(" "waiting process " ("bpendingprocess " waiting process "bprocess " waiting process "bwaiting waiting process "bwaiting waiting waiting waiting finished finished finished coroutinen close(figure sending two items of data to three coroutines to processif one is ever waiting (because it finishes first)the others continue to workwhich minimizes processor idle time once we are finished using the coroutines we call close(on each of themthis stops them from waiting for more datawhich means they won' consume any more processor time to create coroutine in pythonwe simply create function that has at least one yield expression--normally inside an infinite loop when yield is reached the coroutine' execution is suspended waiting for data once the data is received the coroutine resumes processing (from the yield expression onward)and when it has finished it loops back to the yield to wait for more data while one or more coroutines are suspended waiting for dataanother one can execute this can produce greater throughput than simply executing functions one after the other linearly we will show how performing independent operations works in practice by applying several regular expressions to the text in set of html files the purpose is to output each file' urls and level and level headings we'll start by looking at the regular expressionsthen the creation of the coroutine "matchers"and then we will look at the coroutines and how they are used url_re re compile( """href=(? ['"])(? [^\ ]+?)"" """(? =quote)"""re ignorecaseflags re multiline|re ignorecase|re dotall _re re compile( "(? +?)"flagsh _re re compile( "(? +?)"flags