Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   SocketServer.BaseRequestHandler has the data, and now? (http://www.velocityreviews.com/forums/t745374-socketserver-baserequesthandler-has-the-data-and-now.html)

ao11 03-19-2011 12:15 AM

SocketServer.BaseRequestHandler has the data, and now?
 
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


All times are GMT. The time now is 11:38 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.