Back to index

python3.2  3.2.2
Classes | Functions
mp_webserver Namespace Reference

Classes

class  RequestHandler

Functions

def note
def serve_forever
def runpool
def test

Function Documentation

def mp_webserver.note (   format,
  args 
)

Definition at line 26 of file mp_webserver.py.

00026 
00027 def note(format, *args):
00028     sys.stderr.write('[%s]\t%s\n' % (current_process().name, format % args))
00029 

Here is the caller graph for this function:

def mp_webserver.runpool (   address,
  number_of_processes 
)

Definition at line 43 of file mp_webserver.py.

00043 
00044 def runpool(address, number_of_processes):
00045     # create a single server object -- children will each inherit a copy
00046     server = HTTPServer(address, RequestHandler)
00047 
00048     # create child processes to act as workers
00049     for i in range(number_of_processes - 1):
00050         Process(target=serve_forever, args=(server,)).start()
00051 
00052     # main process also acts as a worker
00053     serve_forever(server)
00054 

Here is the call graph for this function:

Here is the caller graph for this function:

def mp_webserver.serve_forever (   server)

Definition at line 35 of file mp_webserver.py.

00035 
00036 def serve_forever(server):
00037     note('starting server')
00038     try:
00039         server.serve_forever()
00040     except KeyboardInterrupt:
00041         pass
00042 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 55 of file mp_webserver.py.

00055 
00056 def test():
00057     DIR = os.path.join(os.path.dirname(__file__), '..')
00058     ADDRESS = ('localhost', 8000)
00059     NUMBER_OF_PROCESSES = 4
00060 
00061     print('Serving at http://%s:%d using %d worker processes' % \
00062           (ADDRESS[0], ADDRESS[1], NUMBER_OF_PROCESSES))
00063     print('To exit press Ctrl-' + ['C', 'Break'][sys.platform=='win32'])
00064 
00065     os.chdir(DIR)
00066     runpool(ADDRESS, NUMBER_OF_PROCESSES)
00067 

Here is the call graph for this function: