On 2/7/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > Liam Clarke wrote: > > Hi all, > > > > About to embark on my first foray into threading, and rather unsure of > > initial approach. I have a basic UDPServer from SocketServer running > > using serve_forever(). I'd like to stick this in a thread where it can > > endlessly loop waiting for incoming packets, and pushing the received > > data into a list where it can be retrieved and operated on by another > > thread, until such time as the controlling app terminates it. > > Threaded servers are supported by the standard library. Instead of using > UDPServer use this class: > class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass > > Then your request handler will be called in a separate thread. You don't > need to queue the requests yourself, the server will create the thread > and dispatch to it when a request is received. > > Kent > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor >
Ah... so then calling serve_forever() won't block? My current code, which illustrates what I'm attempting can be found here - http://www.rafb.net/paste/results/oIqI3Q11.html Basically, the server isn't the main focus, what I'm aiming for looks similar to this server-----Queue--data_cruncher--MySQLconnection server---/ / server-/ / server -/ So basically having data_cruncher to crunch whatever data there is in the queue and send it off to the database is the priority. I'm having trouble with SocketServer, need to do some more experimenting, so I'll get back to it. Regards, Liam Clarke _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor