sched scheduler(sched new(http_server(('', ))sched mainloop(careful study of this example will yield tremendous insight into coroutines and concurrent programming techniques used by some very advanced third-party modules howeverexcessive usage of these techniques might get you fired after your next code review when to consider asynchronous networking use of asynchronous / (asyncore and asynchat)pollingand coroutines as shown in previous examples remains one of the most mysterious aspects of python development yetthese techniques are used more often than you might think an often-cited reason for using asynchronous / is to minimize the perceived overhead of programming with large number of threadsespecially when managing large number of clients and in light of restrictions related to the global interpreter lock (refer to "threads and concurrency"historicallythe asyncore module was one of the first library modules to support asynchronous / the asynchat module followed some time later with the aim of simplifying much of the coding howeverboth of these modules take the approach of processing / as events for examplewhen an / event occursa callback function is triggered the callback then reacts in response to the / event and carries out some processing if you build large application in this styleyou will find that event handling infects almost every part of the application ( / events trigger callbackswhich trigger more callbackswhich trigger other callbacksad nauseumone of the more popular networking packages,twisted (and significantly builds upon it coroutines are more modern but less commonly understood and used since they were only first introduced in python an important feature of coroutines is that you can write programs that look more like threaded programs in their overall control flow for instancethe web server in the example does not use any callback functions and looks almost identical to what you would write if you were using threads--you just have to become comfortable with the use of the yield statement stackless python (as general ruleyou probably should resist the urge to use asynchronous / techniques for most network applications for instanceif you need to write server that constantly transmits data over hundreds or even thousands of simultaneous network connectionsthreads will tend to have superior performance this is because the performance of select(degrades significantly as the number of connections it must monitor increases on linuxthis penalty can be reduced using special functions such as epoll()but this limits the portability of your code perhaps the main benefit of asynchronous / is in applications where networking needs to be integrated with other event loops ( guisor in applications where networking is added into code that also performs significant amount of cpu processing in these casesthe use of asynchronous networking may result in quicker response time lib fl ff