sholden at holdenweb.com
Fri Jan 25 18:55:35 CET 2002
"Hugo Martires" <hugomartires at hotmail.com> wrote ...
> How can i make a ThreadingTCPServer using the SocketServer module ?
> I have read all the information in the module and i still don't get it.
> I also learn how to program threads, but how to use them with SocketServer
> To start, i was doing this:
> #!/usr/bin/env python2
> from SocketServer import *
> import threading
> def main():
> print "Waiting..."
> s = ThreadingTCPServer(ThreadingMixIn, TCPServer)
> what should i do ???
First, try not to use "from x import *" unless you know it to be safe for
print "Got a request"
myServer = SocketServer.ThreadingTCPServer(ADDR,
After that it's all down to your MyRequestHandler class, which will be used
to create an instance every time a client connects. Usually you put your
code in the handle() method, inheriting from SocketServer.BaseRequestHandler
to get the other details right.
Consulting, training, speaking: http://www.holdenweb.com/
Python Web Programming: http://pydish.holdenweb.com/pwp/
More information about the Python-list