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


Groups > comp.lang.python > #44297

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

Path csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; '"""': 0.07; 'assuming': 0.09; 'wrapper': 0.09; 'python': 0.11; 'failure.': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'indexerror:': 0.16; 'it),': 0.16; 'iterable,': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'monitors': 0.16; 'months)': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'seconds.': 0.16; 'subject: \n ': 0.16; 'subject:exception': 0.16; 'subject:program': 0.16; 'subject:skip:m 10': 0.16; 'targets': 0.16; 'underlying': 0.16; 'wing': 0.16; 'subject:python': 0.16; 'exception': 0.16; 'index': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'library': 0.18; 'bit': 0.19; 'trying': 0.19; "python's": 0.19; 'import': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; '(or': 0.24; 'sort': 0.25; 'logging': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'raise': 0.29; 'said,': 0.30; "i'm": 0.30; 'code': 0.31; '(maybe': 0.31; 'catching': 0.31; 'maintenance,': 0.31; 'occurs': 0.31; 'raised': 0.31; 'ray': 0.31; 'file': 0.32; 'run': 0.32; 'quite': 0.32; '(most': 0.33; 'skip:# 10': 0.33; 'subject:the': 0.34; 'could': 0.34; 'basic': 0.35; 'connection': 0.35; 'received:84': 0.35; 'but': 0.35; 'addresses,': 0.36; 'interact': 0.36; 'two': 0.37; 'list': 0.37; 'being': 0.38; 'loss': 0.38; 'checks': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; '12,': 0.39; 'to:addr:python.org': 0.39; 'failures': 0.60; 'range': 0.61; 'simply': 0.61; 'simple': 0.61; 'real': 0.63; 'map': 0.64; 'different': 0.65; 'within': 0.65; 'header:Reply- To:1': 0.67; 'sunday': 0.68; 'reply-to:no real name:2**0': 0.71; 'country': 0.77; 'william': 0.81; 'harness': 0.84; 'launches': 0.84; 'reply-to:addr:python.org': 0.84; 'subject:source': 0.84; 'nights': 0.91; 'hands': 0.96
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=JsTI8qIC c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=7AxPfEIvyrUA:10 a=MxBgixboieMA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=8zeqyWBeVFoA:10 a=CkbKcn_UAAAA:8 a=nD_-jUmVcIWysGEtCqUA:9 a=wPNLvfGTeEIA:10
X-AUTH mrabarnett:2500
Date Wed, 24 Apr 2013 23:54:23 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5
MIME-Version 1.0
To python-list@python.org
Subject Re: Finding the source of an exception in a python multiprocessing program
References <733559EE-CBDC-406A-8018-78CD41E2C445@mac.com>
In-Reply-To <733559EE-CBDC-406A-8018-78CD41E2C445@mac.com>
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
Reply-To python-list@python.org
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.1036.1366844061.3114.python-list@python.org> (permalink)
Lines 37
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366844061 news.xs4all.nl 15994 [2001:888:2000:d::a6]:52184
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44297

Show key headers only | View raw


On 24/04/2013 20:25, William Ray Wing wrote:
> I run a bit of python code that monitors my connection to the greater Internet.  It checks connectivity to the requested target IP addresses, logging both successes and failures, once every 15 seconds.  I see failures quite regularly, predictably on Sunday nights after midnight when various networks are undergoing maintenance.  I'm trying to use python's multiprocessing library to run multiple copies in parallel to check connectivity to different parts of the country (they in no way interact with each other).
>
> On rare occasions (maybe once every couple of months) I get the following exception and traceback:
>
> Traceback (most recent call last):
>    File "./CM_Harness.py", line 12, in <module>
>      Foo = pool.map(monitor, targets)    # and hands off two targets
>    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 227, in map
>      return self.map_async(func, iterable, chunksize).get()
>    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/pool.py", line 528, in get
>      raise self._value
> IndexError: list index out of range
>
> The code where the traceback occurs is:
>
> #!/usr/bin/env python
>
> """ Harness to call multiple parallel copies
>      of the basic monitor program
> """
>
> from multiprocessing import Pool
> from Connection_Monitor import monitor
>
> targets = ["8.8.8.8", "www.ncsa.edu"]
> pool = Pool(processes=2)            # start 2 worker processes
> Foo = pool.map(monitor, targets)    # and hands off two targets
>
>
> Line 12, in my code is simply the line that launches the underlying monitor code.  I'm assuming that the real error is occurring in the monitor program that is being launched, but I'm at a loss as to what to do to get a better handle on what's going wrong. Since, as I said, I see failures quite regularly, typically on Sunday nights after midnight when various networks are undergoing maintenance, I don't _think_ the exception is being triggered by that sort of failure.
>
[snip]
If the exception is being raised by 'monitor', you could try catching
the exception within that (or write a simple wrapper function which
calls it), write the traceback to a logfile, and then re-raise.

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


Thread

Re: Finding the source of an exception in a python multiprocessing program MRAB <python@mrabarnett.plus.com> - 2013-04-24 23:54 +0100

csiph-web