object that represents running task class task(object)def _init_ (self,target)self target target coroutine self sendval none value to send when resuming self stack [call stack def run(self)tryresult self target send(self sendvalif isinstance(result,systemcall)return result if isinstance(result,types generatortype)self stack append(self targetself sendval none self target result elseif not self stackreturn self sendval result self target self stack pop(except stopiterationif not self stackraise self sendval none self target self stack pop(object that represents "system callclass systemcall(object)def handle(self,sched,task)pass scheduler object class scheduler(object)def _init_ (self)self task_queue self read_waiting self write_waiting self numtasks collections deque({{ create new task out of coroutine def new(self,target)newtask task(targetself schedule(newtaskself numtasks + put task on the task queue def schedule(self,task)self task_queue append(taskhave task wait for data on file descriptor def readwait(self,task,fd)self read_waiting[fdtask lib fl ff