Re: Finding the source of an exception in a python multiprocessingprogram

Discussion in 'Python' started by MRAB, Apr 24, 2013.

  1. MRAB

    MRAB Guest

    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 "./", line 12, in <module>
    > Foo =, targets) # and hands off two targets
    > File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/", line 227, in map
    > return self.map_async(func, iterable, chunksize).get()
    > File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/", 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 = ["", ""]
    > pool = Pool(processes=2) # start 2 worker processes
    > Foo =, 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.

    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.
    MRAB, Apr 24, 2013
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads

    finding source jsp from web page, Oct 1, 2003, in forum: Java
    Gerbrand van Dieijen
    Oct 1, 2003
  2. Replies:
    Dave Kelly
    Sep 8, 2006
  3. Subra

    Finding the source files in the binary

    Subra, Aug 7, 2007, in forum: C Programming
    Kenny McCormack
    Aug 9, 2007
  4. Neil Cerutti
    Neil Cerutti
    Apr 25, 2013
  5. Oscar Benjamin
    Oscar Benjamin
    Apr 24, 2013

Share This Page