Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.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.127 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.77; '*S*': 0.03; 'think,': 0.07; 'caller': 0.09; 'counting': 0.09; 'friday,': 0.09; 'thread': 0.14; '__del__': 0.16; 'called.': 0.16; 'destroyed.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'reliably': 0.16; 'wrote:': 0.18; 'paul': 0.24; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'usually': 0.31; 'sep': 0.31; 'fri,': 0.33; 'problem': 0.35; "can't": 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'that!': 0.36; 'sometimes': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'called': 0.40; 'even': 0.60; 'subject: / ': 0.60; "you'll": 0.62; 'here': 0.66; 'bottom': 0.67; 'hang': 0.67; 'ending': 0.78; 'cycles.': 0.84; 'promptly': 0.84; 'subject:skip:M 10': 0.84; 'technically': 0.84; 'wow': 0.84; 'reliable,': 0.93; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=q4ZaMO7rpHzHiI8mm/ziUl5WvlRcBai6JIeUJDw9jCM=; b=RQm1TNq4K03RYb7NCjFK3HJLKy+5lekKVAq4NmS/DnTW7NLulNRuQliqO907lzjpZV MiyIJdUO+K/NQHz5nFLOk/OfVOuypiivDyiMNXzpHEReXmiwqgc3dN+v1XRuM1vQ/A9Z 7QXh3ubP5P/56FhSucxnSlY6DWdjURCqsvkm358QNYdEwmE7jpjV44tA7k0PY006RdVX e6XxiXmQmF2oC1VuM3GWlmRVeswf7AWW8LY6m7tONrUpV42wZv/putQl24McIsf85s3t iJMkc3ntfJdbngng1ijrZYhcOEgF++VeN6Qf1Cz3r0HpdIfcAmnY6g7Uhv9ZwDZ2LwSV tQ/A== MIME-Version: 1.0 X-Received: by 10.220.181.136 with SMTP id by8mr85006vcb.11.1378436449117; Thu, 05 Sep 2013 20:00:49 -0700 (PDT) In-Reply-To: <9d088493-8224-4a48-a2d3-5b7207dc8947@googlegroups.com> References: <9d088493-8224-4a48-a2d3-5b7207dc8947@googlegroups.com> Date: Fri, 6 Sep 2013 13:00:49 +1000 Subject: Re: Multiprocessing / threading confusion From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1378436451 news.xs4all.nl 15863 [2001:888:2000:d::a6]:58880 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53752 On Fri, Sep 6, 2013 at 9:34 AM, Paul Pittlerson wrote: > On Friday, September 6, 2013 1:28:39 AM UTC+3, mar...@python.net wrote: > >> Also you can't (and shouldn't) depend on the time that __del__ gets >> called. It can get called at any time, in any order and sometimes not >> at all.* > > Wow I did not know that! I was counting on that it reliably gets called when the object is destroyed. Even that isn't technically reliable, though in CPython, objects will usually be __del__'d promptly as long as they're not in reference cycles. But the main problem here is that the destruction of the object has nothing to do with the ending of the thread or process; the object will hang around for as long as the caller might want it. You'll want to put your "end of process" code at the bottom of run(), I think, unless there's some other place for it. ChrisA