the use of readwait and writewait might look rather low-level fortunatelyour design allows these operations to be hidden behind library functions and methods-provided that they are also coroutines consider the following object that wraps socket object and mimics its interfaceclass cosocket(object)def _init_ (self,sock)self sock sock def close(self)yield self sock close(def bind(self,addr)yield self sock bind(addrdef listen(self,backlog)yield self sock listen(backlogdef connect(self,addr)yield writewait(self sockyield self sock connect(addrdef accept(self)yield readwait(self sockconnaddr self sock accept(yield cosocket(conn)addr def send(self,bytes)while bytesevt yield writewait(self socknsent self sock send(bytesbytes bytes[nsent:def recv(self,maxsize)yield readwait(self sockyield self sock recv(maxsizehere is reimplementation of the time server using the cosocket classfrom socket import socketaf_inetsock_stream def time_server(address)import time cosocket(socket(af_inet,sock_stream)yield bind(addressyield listen( while trueconn,addr yield accept(print(connprint("connection from %sstr(addr)resp time ctime()+"\ \nyield conn send(resp encode('latin- ')yield conn close(sched scheduler(sched new(time_server(('', ))sched new(time_server(('', ))sched run(server on port server on port in this examplethe programming interface of cosocket object looks lot like normal socket the only difference is that every operation must be prefaced with yield (since every method is defined as coroutineat firstit looks crazy so you might ask what does all of this madness buy youif you run the above serveryou will find that it is able to run concurrently without using threads or subprocesses not only thatit has "normallooking control flow as long as you ignore all of the yield keywords lib fl ff