Hello,

I am having trouble getting the ThreadingMixIn to do what I want.
Looking over the docs (and some old code I wrote which successfully
does what I want), I arrived at the following:

import time
import SocketServer
import BaseHTTPServer

class TheServer(SocketServer.ThreadingMixIn,
BaseHTTPServer.HTTPServer):
    pass

class TheHandler(BaseHTTPServer.BaseHTTPRequestHandler):
    def do_GET(self):
        print "sleeping..."
        time.sleep(10)
        print "awake!"

if __name__ == "__main__":
    theServer = TheServer(('', 8083), TheHandler)
    theServer.serve_forever()

I would like this server to print "sleeping..." when someone make a
request, waits 10 seconds, then prints "awake!"  This works, but it
does not exhibit threading behavior; i.e. it handles the requests in
sequential order:
sleeping...
awake!
sleeping...
awake!

Is there some problem with using the time.sleep() method?  Or have I
done something else wrong?  Sorry for asking such a simple question,
but it seems I am unable to pinpoint my error.

Thanks.

--Rob

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to