Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.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.026 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'raises': 0.07; 'exceptions': 0.09; 'tasks,': 0.09; 'am,': 0.14; 'received:209.85.214.174': 0.14; 'received:mail- iw0-f174.google.com': 0.14; 'wrote:': 0.14; '(starting': 0.16; 'angelico': 0.16; 'exception?': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'ioerror': 0.16; 'propagate': 0.16; 'subject:stop': 0.16; 'mon,': 0.17; 'operations.': 0.19; 'header:In-Reply-To:1': 0.21; 'seems': 0.21; 'detect': 0.22; 'loop,': 0.23; 'code': 0.24; 'function': 0.25; 'subject: : ': 0.26; "i'm": 0.27; 'message-id:@mail.gmail.com': 0.28; 'received:209.85.214': 0.28; 'do.': 0.30; 'asynchronous': 0.30; 'threads': 0.30; 'calling': 0.31; 'usually': 0.32; "can't": 0.32; 'to:addr:python-list': 0.33; 'list': 0.33; "i've": 0.33; 'chris': 0.34; 'one,': 0.34; 'normally': 0.34; 'showing': 0.34; 'using': 0.35; 'tasks': 0.36; 'received:google.com': 0.37; 'received:209.85': 0.37; '20,': 0.37; 'parallel': 0.37; 'thread': 0.37; 'pretty': 0.37; 'run': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'doing': 0.39; 'should': 0.39; 'received:209': 0.39; 'finished': 0.39; 'to:addr:python.org': 0.39; 'almost': 0.60; 'simply': 0.60; 'you.': 0.62; 'show': 0.66; 'share': 0.67; 'here.': 0.69; 'subject:make': 0.73; 'hand,': 0.74; '12:42': 0.84; 'perform.': 0.84; 'immediately,': 0.91; 'completion': 0.97 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=hjJBkeFwZBlLy4Ur/jOHY+Wu3hnQ5diOlSJN8pUaTp8=; b=CkCTSiaje1xuFFpUcU8Aqc/0l0q+G1LdWcwXY9CEl/vNRYP6igJS6mB08Pvi9gEjBT fDW2oay+xjuo63tkbDNAte2lbnf7Qyx8MatzPW03Pyi2/2KgE07M08SjQmIJf0yH3w02 EpKfqg7/RGFvJLL5xN3DVZMHakevKj/4pDW3c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=ABN2GONxwUIhV7dhj/Q84JYGKSFQGOupBHfUYKrFBQW4pzA5NUgF6EernwUnX6Hh3K sgdHRqoO0h7hiT8roWQl96E5N1yASmYnvt+6f1n4yEiRqpaC8bIzqDtIhXEwnz90YFrN IrDSS42XoQf78Da5gMjCmXKByTb87A+UASLJw= MIME-Version: 1.0 In-Reply-To: References: Date: Mon, 20 Jun 2011 01:19:34 +1000 Subject: Re: threading : make stop the caller From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 31 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308496777 news.xs4all.nl 49174 [::ffff:82.94.164.166]:35381 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:7970 On Mon, Jun 20, 2011 at 12:42 AM, Laurent Claessens w= rote: > =A0 Hello > > > I've a list of tasks to perform. Each of them is a threading.Thread. > Basically I have : > > while task_list : > =A0 task =3D task_list[0] > =A0 task.run() > =A0 task_list.remove(task) I'm not understanding what you're doing with threads here. Are you using threading.Thread but then calling its run() method synchronously? Normally threads are used for asynchronous operations. You would then use the start() method to spin the thread off; it will return almost immediately, and the thread will run to completion in parallel with you. But then you can't halt the main loop, because it will have already finished by the time you detect the IOError (starting a bunch of threads is pretty quick). On the other hand, the code you're showing seems to simply call each thread's run() method one by one, which should propagate any exceptions in the same way that function calls usually do. Can you share the code for one of the tasks, and show what happens when it raises an exception? Chris Angelico