the task class represents running task and is just thin layer on top of coroutine task object task has only one operationtask run(this resumes the task and runs it until it hits the next yield statementat which point the task suspends when running taskthe task sendval attribute contains the value that is to be sent into the task' corresponding yield expression tasks run until they encounter the next yield statement the value produced by this yield controls what happens next in the taskn if the value is another coroutine (type generatortype)it means that the task wants to temporarily transfer control to that coroutine the stack attribute of task objects represents call-stack of coroutines that is built up when this happens the next time the task runscontrol will be transferred into this new coroutine if the value is systemcall instanceit means that the task wants the scheduler to do something on its behalf (such as launch new taskwait for /oand so onthe purpose of this object is described shortly if the value is any other valueone of two things happens if the currently executing coroutine was running as subroutineit is popped from the task call stack and the value saved so that it can be sent to the caller the caller will receive this value the next time the task executes if the coroutine is the only executing coroutinethe return value is simply discarded the handling of stopiteration is to deal with coroutines that have terminated when this happenscontrol is returned to the previous coroutine (if there was oneor the exception is propagated to the scheduler so that it knows that the task terminated the systemcall class represents system call in the scheduler when running task wants the scheduler to carry out an operation on its behalfit yields systemcall instance this object is called "system callbecause it mimics the behavior of how programs request the services of real multitasking operating system such as unix or windows in particularif program wants the services of the operating systemit yields control and provides some information back to the system so that it knows what to do in this respectyielding systemcall is similar to executing kind of system "trap the scheduler class represents collection of task objects that are being managed at its corethe scheduler is built around task queue (the task_queue attributethat keeps track of tasks that are ready to run there are four basic operations concerning the task queue new(takes new coroutinewraps it with task objectand places it on the work queue schedule(takes an existing task and puts it back on the work queue mainloop(runs the scheduler in loopprocessing tasks one by one until there are no more tasks the readwait(and writewait(methods put task object into temporary staging areas where it will wait for / events in this casethe task isn' runningbut it' not dead either--it' just sitting around biding its time the mainloop(method is the heart of the scheduler this method first checks to see if any tasks are waiting for / events if soit arranges call to select(in order to poll for / activity if there are any events of interestthe associated tasks are placed back onto the task queue so that they can run nextthe mainloop(method pops tasks off of the task queue and calls their run( lib fl ff