network programming and sockets have task wait for writing on file descriptor def writewait(self,task,fd)self write_waiting[fdtask main scheduler loop def mainloop(self,count=- ,timeout=none)while self numtaskscheck for / events to handle if self read_waiting or self write_waitingwait if self task_queue else timeout , , select select(self read_waitingself write_waiting[]waitfor fileno in rself schedule(self read_waiting pop(fileno)for fileno in wself schedule(self write_waiting pop(fileno)run all of the tasks on the queue that are ready to run while self task_queuetask self task_queue popleft(tryresult task run(if isinstance(result,systemcall)result handle(self,taskelseself schedule(taskexcept stopiterationself numtasks - if no tasks can runwe decide if we wait or return elseif count count - if count = return implementation of different system calls class readwait(systemcall)def _init_ (self, )self def handle(self,sched,task)fileno self fileno(sched readwait(task,filenoclass writewait(systemcall)def _init_ (self, )self def handle(self,sched,task)fileno self fileno(sched writewait(task,filenoclass newtask(systemcall)def _init_ (self,target)self target target def handle(self,sched,task)sched new(self targetsched schedule(taskthe code in this example implements very tiny "operating system here are some details concerning its operationn all work is carried out by coroutine functions recall that coroutine uses the yield statement like generator except that instead of iterating on ityou send it values using send(valuemethod lib fl ff