0

How is it possible to determine what line an error occurred on while using the multiprocessing package in Python? For example I currently get an error similar to:

File "C:\Users\user\file.py", line 76, in <module>
  loop_over()
File "C:\Users\user\file.py", line 56, in loop_over
  results = [pool.apply(process_file, args=(file_name,year)) for file_name in files_in_folder]
File "C:\Python27\lib\multiprocessing\pool.py", line 244, in apply
  return self.apply_async(func, args, kwds).get()
File "C:\Python27\lib\multiprocessing\pool.py", line 567, in get
  raise self._value
KeyError: 'column_a'

In this instance, all i know is that the 'KeyError' arose somewhere after the multiprocessing was called [i.e it results somewhere in the function proecess_filethat was called on line 56], but no more specifics over what actual line of my code caused the error.

kyrenia
  • 5,431
  • 9
  • 63
  • 93
  • There doesn't seem to be a standard solution for Py2, see [this question](http://stackoverflow.com/questions/6728236/exception-thrown-in-multiprocessing-pool-not-detected) (although you can write a custom exception-logging decorator). Fixed in Py3.4, where the actual traceback from the worker is printed. – fjarri Nov 18 '15 at 01:49
  • ... this may the straw which finally pushes me onto Py3 – kyrenia Nov 18 '15 at 01:52

0 Answers0