[ python-Bugs-1742837 ] Documentation for BaseHTTPServer.HTTPServer
SourceForge.net
noreply at sourceforge.net
Mon Jun 25 15:24:09 CEST 2007
Bugs item #1742837, was opened at 2007-06-25 09:24
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742837&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Brandon Mintern (bmintern)
Assigned to: Nobody/Anonymous (nobody)
Summary: Documentation for BaseHTTPServer.HTTPServer
Initial Comment:
I have frequently used the BaseHTTPServer.HTTPServer class to create servers to perform a variety of tasks. In the past, I have always simply created an instance of the class and invoked "serve_forever" (as shown in http://docs.python.org/lib/module-BaseHTTPServer.html).
This time around, however, I needed to be able to run the server inside a while loop, so that I could eventually terminate the server. The docs.python.org site has no real documentation indicating how to do this, since the HTTPServer class is not really documented. I found the information I needed at http://pydoc.org/2.4.1/BaseHTTPServer.html#HTTPServer.
This is a request to include more information on HTTPServer on the docs.python.org site, especially documentation for functions like handle_request(). I understand that HTTPServer inherits from SocketServer.TCPServer, which inherits from SocketServer.BaseServer, and that is where this method comes from. For this reason, it doesn't really make sense to duplicate that information. I would simply like to see another use case to supplement the first one, i.e.
## What is there already
def run(server_class=BaseHTTPServer.HTTPServer,
handler_class=BaseHTTPServer.BaseHTTPRequestHandler):
server_address = ('', 8000)
httpd = server_class(server_address, handler_class)
httpd.serve_forever()
## I would like to see something like the following added
def run_while_true(keep_running,
server_class=BaseHTTPServer.HTTPServer,
handler_class=BaseHTTPServer.BaseHTTPRequestHandler):
"""keep_running is a function of no arguments which is tested initially and
after each request. If its return value evaluates to True, the server
continues."""
server_address = ('', 8000)
httpd = server_class(server_address, handler_class)
while keep_running:
httpd.handle_request()
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742837&group_id=5470
More information about the Python-bugs-list
mailing list