problem with ThreadingTCPServer Handler
David M Chess
chess at us.ibm.com
Tue Oct 23 16:40:05 EDT 2012
> jorge <jaorozco at estudiantes.uci.cu>
> I'm programming a server that most send a message to each client
> connected to it and nothing else. this is obviously a base of what i
> want to do. the thing is, I made a class wich contains the Handler class
> for the ThreadingTCPServer and starts the server but i don't know how
> can i access the message variable contained in the class from the
> Handler since I have not to instance the Handler by myself.
The information about the request is in attributes of the Handler object.
>From the socketserver docs (
http://docs.python.org/library/socketserver.html ):
RequestHandler.handle()
This function must do all the work required to service a request. The
default implementation does nothing. Several instance attributes are
available to it; the request is available as self.request; the client
address asself.client_address; and the server instance as self.server, in
case it needs access to per-server information.
If that's what you meant by "the message variable contained in the class".
If, on the other hand, you meant that you want to pass some specific data
into the handler about what it's supposed to be doing, I've generally
stashed that in the server, since the handler can see the server via
self.server.
DC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121023/f757709f/attachment.html>
More information about the Python-list
mailing list