Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'cpython': 0.05; 'socket': 0.05; 'subject:skip:s 10': 0.05; 'try:': 0.07; 'exception:': 0.09; 'happens.': 0.09; 'port))': 0.09; 'subclass': 0.09; 'thread,': 0.09; 'def': 0.10; 'sock': 0.16; 'sock.close()': 0.16; 'subject:questions': 0.16; 'subject:threads': 0.16; 'threading': 0.16; 'wrote:': 0.17; 'windows': 0.19; 'import': 0.21; 'defined': 0.22; 'errors': 0.23; 'somebody': 0.23; 'raise': 0.24; 'host': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'subject:/': 0.28; 'run': 0.28; 'queue': 0.29; 'probably': 0.29; 'stuff': 0.30; 'code': 0.31; 'point': 0.31; 'getting': 0.33; 'asked': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'false': 0.35; 'received:192.168.0': 0.35; 'created': 0.36; 'except': 0.36; 'but': 0.36; 'message- id:@gmail.com': 0.36; "didn't": 0.36; 'should': 0.36; 'skip:p 20': 0.36; 'subject:http': 0.37; 'why': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'things': 0.38; 'nothing': 0.38; 'shows': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'subject:-': 0.40; 'help': 0.40; 'real': 0.61; 'mentioned': 0.63; 'different': 0.63; 'here': 0.65; '9.1': 0.84; 'researched': 0.84; 'anywhere,': 0.93; 'subject:chat': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=NctcysLLLRk6KzNKSFI9Vg6wafPAiJwxKfUuaS0AAAI=; b=vdNlPKv7qbWRvmAFAgRTc2kYEXg87LiTyvNtRQSH1JGK640biamwULOKrFY7rptaFW ANLwXTlVEBkMEBbcuwW64/qSX6/dxdyEYYDIsW46PIqIgAGo2i745PwgECtZrf1CVBSM Bi2Mmzrr47PtK92iel2wPFy5RUkXRLY1a6dzVXKjODynQ6X3YHj7RhotpMnnYjuWuu/S Yfk/72XeFRqKxUUApfiVsZjcclzpihSFnHR3CIQ45z0Y5JyXhVp/II5HiWfDxQab/VB1 yW0oiZYcGMW8QWfI8mujSCLW9D8pd+hD1mZVIUlxPCzvikyfAr0XlM+EWT8jx3TutUMW sDzQ== X-Received: by 10.50.135.8 with SMTP id po8mr2728087igb.41.1362846949610; Sat, 09 Mar 2013 08:35:49 -0800 (PST) Date: Sat, 09 Mar 2013 10:35:49 -0600 From: Andrew Berg User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: "comp.lang.python" Subject: Re: http://stackoverflow.com/questions/15311450/my-chat-client-freezes-up-after-beginning-threads References: In-Reply-To: X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=UTF-8 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362846957 news.xs4all.nl 6912 [2001:888:2000:d::a6]:47162 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40957 On 2013.03.09 09:26, Owatch wrote: > Thing is, when I run the program. Nothing happens. > > Can somebody help point out what is wrong? (I've asked questions and researched for 3 days, without getting anywhere, so I did try) You defined a thread, but never created or started it. Also, why did you subclass threading.Thread? You also mentioned queues, but you didn't use them. Not tested, but shows the basics: import threading import queue import socket def process(): while alive: thing = things_to_process.get() # do stuff with the thing here things_to_process.task_done() alive = True host = 'localhost' port = 9999 things_to_process = queue.Queue() process_thread = threading.Thread(target=process) process_thread.start() sock = socket.socket() sock.connect((host, port)) while alive: try: data = sock.recv() except Exception: # should probably do different things for different errors in real code alive = False sock.close() process_thread.join() raise else: things_to_process.put(data) -- CPython 3.3.0 | Windows NT 6.2.9200 / FreeBSD 9.1