Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31932 > unrolled thread

problem with ThreadingTCPServer Handler

Started byjorge <jaorozco@estudiantes.uci.cu>
First post2012-10-23 10:36 -0400
Last post2012-10-23 13:51 -0700
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  problem with ThreadingTCPServer Handler jorge <jaorozco@estudiantes.uci.cu> - 2012-10-23 10:36 -0400
    Re: problem with ThreadingTCPServer Handler Miki Tebeka <miki.tebeka@gmail.com> - 2012-10-23 13:51 -0700
    Re: problem with ThreadingTCPServer Handler Miki Tebeka <miki.tebeka@gmail.com> - 2012-10-23 13:51 -0700

#31932 — problem with ThreadingTCPServer Handler

Fromjorge <jaorozco@estudiantes.uci.cu>
Date2012-10-23 10:36 -0400
Subjectproblem with ThreadingTCPServer Handler
Message-ID<mailman.2666.1351003524.27098.python-list@python.org>
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.
here is the base code of what I'm doing.

import SocketServer
import socket
from threading import Thread

class CustomTCPServer:
     msg = "no message"
     outport = 8080

     class Handler(SocketServer.BaseRequestHandler):
         def handle(self):
             self.request.sendall('<here goes msg from CustomTCPServer>')


     def __init__(self,msg,outport):
         self.msg = server
         self.outport = outport

     def runServer(self):
         addr = ('',self.outport)
         s = SocketServer.ThreadingTCPServer(addr,self.Handler)
         r = Thread(target=s.serve_forever).start()
         print '> Server running running',self.server,self.outport


CustomTCPServer('msg1',1212).runServer()
CustomTCPServer('msg2',1213).runServer()

can anyone please help me?

10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS INFORMATICAS...
CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION

http://www.uci.cu
http://www.facebook.com/universidad.uci
http://www.flickr.com/photos/universidad_uci

[toc] | [next] | [standalone]


#31959

FromMiki Tebeka <miki.tebeka@gmail.com>
Date2012-10-23 13:51 -0700
Message-ID<caf71039-d50d-4e12-947d-035ab0282ac3@googlegroups.com>
In reply to#31932
According to the docs (http://docs.python.org/library/socketserver.html#requesthandler-objects) there's self.server available.

[toc] | [prev] | [next] | [standalone]


#31960

FromMiki Tebeka <miki.tebeka@gmail.com>
Date2012-10-23 13:51 -0700
Message-ID<mailman.2693.1351025510.27098.python-list@python.org>
In reply to#31932
According to the docs (http://docs.python.org/library/socketserver.html#requesthandler-objects) there's self.server available.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web