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
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