the following function is used to start the event loop and process eventsloop([timeout [use_poll [map [count]]]]polls for events indefinitely the select(function is used for polling unless the use_poll parameter is truein which case poll(is used instead timeout is the timeout period and is set to seconds by default map is dictionary containing all the channels to monitor count specifies how many polling operations to perform before returning if count is none (the default)loop(polls forever until all channels are closed if count is the function will execute single poll for events and return example the following example implements minimalistic web server using asyncore it implements two classes--asynhttp for accepting connections and asynclient for processing client requests this should be compared with the example in the asynchat module the main difference is that this example is somewhat lower-level--requiring us to worry about breaking the input stream into linesbuffering excess dataand identifying the blank line that terminates the request header an asynchronous http server import asyncoresocket import os import mimetypes import collections tryfrom http client import responses except importerrorfrom httplib import responses python python this class merely handles accept events class async_http(asyncore dispatcher)def _init_ (self,port)asyncore dispatcher _init_ (selfself create_socket(socket af_inet,socket sock_streamself setsockopt(socket sol_socketsocket so_reuseaddr self bind(('',port)self listen( def handle_accept(self)client,addr self accept(return async_http_handler(clienthandle clients class async_http_handler(asyncore dispatcher)def _init_ (selfsock none)asyncore dispatcher _init_ (self,sockself got_request false self request_data "self write_queue collections deque(self responding false read http requestonly readable if request header not read def readable(self)return not self got_request lib fl ff