SocketServer.BaseRequestHandler has the data, and now?

A

ao11

Hello,

I wrote a test application to play around with UDP, the receiving part
looks like:

class proxyServer(SocketServer.ThreadingMixIn,
SocketServer.UDPServer):
pass

class proxyHandler(SocketServer.BaseRequestHandler):

def handle(self):
data = self.request[0]
source = self.request[1]
cur_thread = threading.currentThread()
response = "%s - %s: %s" % (cur_thread.getName(), source,
data)
print response

class proxy(process) :

def __init__(self, id, context) :
process.__init__(self, id, context, self.run())
self.server = proxyServer(("", 58889), proxyHandler)
self.thread =
threading.Thread(target=self.server.serve_forever)
self.thread.setDaemon(True)

def __del__(self) :
if self.server != None :
self.server.shutdown()

def run(self) :
self.context.model.register(self)
self.thread.start()
...
...
...

def notify(self) :
print "notify " + str(self.id)

So far so good, but how do I get the data back from the handle method
to somewhere else? In my case I yust would like to add every incoming
datagram to a queue and process it later in a different thread.

How do I hand over the queue to the class
proxyHandler(SocketServer.BaseRequestHandler)?

thanks,

AO
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top