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


Groups > comp.lang.python > #44303

Re: Finding the source of an exception in a python multiprocessing program

Path csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <oscar.j.benjamin@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'attribute': 0.07; 'failing': 0.07; 'get(self,': 0.09; 'hiding': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; 'def': 0.12; '24,': 0.16; 'letting': 0.16; 'processes.': 0.16; 'seconds.': 0.16; 'storing': 0.16; 'subject:exception': 0.16; 'subject:program': 0.16; 'subject:skip:m 10': 0.16; 'threads,': 0.16; 'top-level': 0.16; 'underlying': 0.16; 'wing': 0.16; 'subject:python': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'module': 0.19; '>>>': 0.22; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; 'module,': 0.24; 'sorry,': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'somewhere': 0.26; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'raise': 0.29; 'thus': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; '(unless': 0.31; '>>>>': 0.31; 'context.': 0.31; 'crash': 0.31; 'ray': 0.31; 'routine': 0.31; 'class': 0.32; 'url:python': 0.33; 'guess': 0.33; 'actual': 0.34; 'subject:the': 0.34; "i'd": 0.34; 'received:google.com': 0.35; 'there': 0.35; 'interact': 0.36; 'library.': 0.36; 'scheduled': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'should': 0.36; 'clear': 0.37; 'pm,': 0.38; 'rather': 0.38; 'anything': 0.39; 'url:mail': 0.40; 'dave': 0.60; 'most': 0.60; "you're": 0.61; 'you.': 0.62; 'more': 0.64; 'further,': 0.74; 'william': 0.81; 'completes': 0.84; 'oscar': 0.84; 'subject:source': 0.84; '2013,': 0.91; 'angel': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=5cxybrGDxVLFiqzEAeclgbVNcGKDHngQe2P+idUmDLs=; b=hUOMrxKu9sX8CKuTY026X8iOma3yufkg57mIALEBFPfCnnloeHAV9OfqWw/UWFulzn xNxeJluivrlo5zgdLYxQRlKAZEOXRI417wSglNY13+7/uEpO7xuRMqrEnrnE4ViuOTHe 2rx+oou6JTeJu05zvRIcHUo1e3t6/tFaYsd9yQf4/iF3ezgb3BAFoG+LOztYNapRwwUm cNXUPH4A+2iFBuqJTcbm+tT+40ZUeL+yj/l4SssZMQe1el/sFQOIf1/qr7/lHLFJDK28 99/dRouZeZ+krNjzkdQkmkmyPFrY4kzdaccgOfXeq4v8uG+LGyOZXYjAdLLBhPwb0nEH TMDA==
X-Received by 10.52.170.107 with SMTP id al11mr14659325vdc.123.1366848074937; Wed, 24 Apr 2013 17:01:14 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <51786A2C.4020306@davea.name>
References <mailman.1032.1366835159.3114.python-list@python.org> <atqtpaFa3niU2@mid.individual.net> <5BC4D9D9-D757-40F3-81CA-CF4FA5C73A96@mac.com> <51786A2C.4020306@davea.name>
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Date Thu, 25 Apr 2013 01:00:54 +0100
Subject Re: Finding the source of an exception in a python multiprocessing program
To Dave Angel <davea@davea.name>
Content-Type text/plain; charset=ISO-8859-1
Cc python-list@python.org
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.1039.1366848077.3114.python-list@python.org> (permalink)
Lines 65
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366848077 news.xs4all.nl 15967 [2001:888:2000:d::a6]:38824
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44303

Show key headers only | View raw


On 25 April 2013 00:26, Dave Angel <davea@davea.name> wrote:
> On 04/24/2013 05:09 PM, William Ray Wing wrote:
>>
>> On Apr 24, 2013, at 4:31 PM, Neil Cerutti <neilc@norwich.edu> wrote:
>>
>>> On 2013-04-24, William Ray Wing <wrw@mac.com> wrote:
>>>>
>>>> When I look at the pool module, the error is occurring in
>>>> get(self, timeout=None) on the line after the final else:
>>>>
>>>>     def get(self, timeout=None):
>>>>         self.wait(timeout)
>>>>         if not self._ready:
>>>>             raise TimeoutError
>>>>         if self._success:
>>>>             return self._value
>>>>         else:
>>>>             raise self._value
>>>
>>>
>>> The code that's failing is in self.wait. Somewhere in there you
>>> must be masking an exception and storing it in self._value
>>> instead of letting it propogate and crash your program. This is
>>> hiding the actual context.
>>>
>>> --
>>> Neil Cerutti
>>> --
>>> http://mail.python.org/mailman/listinfo/python-list
>>
>>
>> I'm sorry, I'm not following you.  The "get" routine (and thus self.wait)
>> is part of the "pool" module in the Python multiprocessing library.
>> None of my code has a class or function named "get".
>>
>> -Bill
>>
>
> My question is why bother with multithreading?  Why not just do these as
> separate processes?  You said "they in no way interact with each other" and
> that's a clear clue that separate processes would be cleaner.

It's using multiprocessing rather than threads: they are separate processes.

>
> Without knowing anything about those libraries, I'd guess that somewhere
> they do store state in a global attribute or equivalent, and when that is
> accessed by both threads, it can crash.

It's state that is passed to it by the subprocess and should only be
accessed by the top-level process after the subprocess completes (I
think!).

>
> Separate processes will find it much more difficult to interact, which is a
> good thing most of the time.  Further, they seem to be scheduled more
> efficiently because of the GIL, though that may not make that much
> difference when you're time-limited by network data.

They are separate processes and do not share the GIL (unless I'm very
much mistaken). Also I think the underlying program is limited by the
call to sleep for 15 seconds.


Oscar

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


Thread

Finding the source of an exception in a python multiprocessing program William Ray Wing <wrw@mac.com> - 2013-04-24 15:25 -0400
  Re: Finding the source of an exception in a python multiprocessing program Neil Cerutti <neilc@norwich.edu> - 2013-04-24 20:31 +0000
    Re: Finding the source of an exception in a python multiprocessing program William Ray Wing <wrw@mac.com> - 2013-04-24 17:09 -0400
      Re: Finding the source of an exception in a python multiprocessing program Neil Cerutti <neilc@norwich.edu> - 2013-04-25 12:37 +0000
    Re: Finding the source of an exception in a python multiprocessing program Dave Angel <davea@davea.name> - 2013-04-24 19:26 -0400
    Re: Finding the source of an exception in a python multiprocessing program Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-04-25 01:00 +0100
    Re: Finding the source of an exception in a python multiprocessing program Dave Angel <davea@davea.name> - 2013-04-24 20:11 -0400

csiph-web