[Stackless] SimpleHTTPServer on stackless 2.5.1
Jim
jimsfba at aol.com
Sat May 12 20:56:17 CEST 2007
Hi, I made a slight modification on the stackless simple web server
example to the following in order to use the functionality o f
SimpleHTTPServer class.
The server works fine for directory list, browsing small files. But when
I tried to load any medium size html (> 200K) , it will block right away at
Traceback (most recent call last):
File "test.py", line 56, in <module>
stackless.run()
File "stacklesssocket.py", line 65, in ManageSockets
asyncore.poll(0.05)
File "C:\Python25\lib\asyncore.py", line 121, in poll
r, w, e = select.select(r, w, e, timeout)
and then no more response.
I am using Python 2.5.1 for windows
http://www.python.org/ftp/python/2.5.1/python-2.5.1.msi
+
http://www.stackless.com/binaries/stackless-python-251.zip
+
http://stacklessexamples.googlecode.com/svn/trunk/examples/networking/stacklesssocket.py
Any suggestion is appreciated. Thanks in advanced.
- Jim
###################################
import sys, time
import stacklesssocket
sys.modules["socket"] = stacklesssocket
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import SimpleHTTPServer
import urlparse, logging
import string, urllib
import stackless
class RequestHandler( SimpleHTTPServer.SimpleHTTPRequestHandler ):
protocol_version = "HTTP/1.1"
def do_GET(self):
# if ( check uri for normal file requests... ) :
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET (self)
# else:
# do other handling for some specific urls
# self.send_response( 200)
# self.send_header("Content-type", "text/html")
# self.send_header("Content-Length", len(response_text))
# self.end_headers()
# self.wfile.write( response_text );
class StacklessHTTPServer(HTTPServer):
def handle_request(self):
try:
request, client_address = self.get_request()
except socket.error:
return
stackless.tasklet(self.handle_request_tasklet)(request,
client_address)
def handle_request_tasklet(self, request, client_address):
if self.verify_request(request, client_address):
try:
self.process_request(request, client_address)
except:
self.handle_error(request, client_address)
self.close_request(request)
def Run():
server = StacklessHTTPServer(('', 8001), RequestHandler )
server.serve_forever()
if __name__ == "__main__":
stackless.tasklet(Run)()
stackless.run()
# web server running at http://127.0.0.1:8001/
###########################################
_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless
More information about the Stackless
mailing list