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


Groups > comp.lang.python > #31932

problem with ThreadingTCPServer Handler

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <jaorozco@estudiantes.uci.cu>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.036
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'handler': 0.04; 'socket': 0.05; 'msg': 0.07; 'addr': 0.09; 'def': 0.10; 'thread': 0.11; 'socketserver': 0.16; 'threading': 0.16; 'instance': 0.17; 'obviously': 0.18; 'variable': 0.20; 'import': 0.21; 'do.': 0.21; 'subject:problem': 0.22; 'skip:_ 20': 0.22; 'programming': 0.23; 'connected': 0.24; 'header:User-Agent:1': 0.26; 'received:10.0.0': 0.28; '"no': 0.29; 'starts': 0.29; 'class': 0.29; "i'm": 0.29; 'code': 0.31; 'running': 0.32; 'print': 0.32; 'skip:h 40': 0.33; 'received:10.0': 0.33; 'anyone': 0.33; 'to:addr:python-list': 0.33; 'me?': 0.33; 'server': 0.35; 'but': 0.36; 'header:Received:9': 0.36; 'client': 0.36; 'subject:with': 0.36; 'nothing': 0.38; 'received:10': 0.38; 'to:addr:python.org': 0.39; 'help': 0.40; 'most': 0.61; 'received:unknown': 0.63; 'here': 0.65; 'else.': 0.65; 'subject:skip:T 10': 0.65; 'url:facebook': 0.67; 'received:200': 0.71; 'futuro,': 0.84; 'message"': 0.84; 'universidad': 0.84; 'url:photos': 0.84; 'url:cu': 0.91
X-Virus-Scanned amavisd-new at uci.cu
Date Tue, 23 Oct 2012 10:36:00 -0400
From jorge <jaorozco@estudiantes.uci.cu>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121011 Thunderbird/16.0.1
MIME-Version 1.0
To python-list@python.org
Subject problem with ThreadingTCPServer Handler
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2666.1351003524.27098.python-list@python.org> (permalink)
Lines 43
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1351003524 news.xs4all.nl 6914 [2001:888:2000:d::a6]:59194
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:31932

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

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

csiph-web