On 06/19/2015 04:25 PM, Andres Riancho wrote:
Fabien,
My recommendation is that you should pass some extra arguments to the task:
* A unique task id
* A result multiprocessing.Queue
When an exception is raised you put (unique_id, exception) to the
queue. When it succeeds you put (unique_id, None). In the main process
you consume the queue and do your error handling.
Note that some exceptions can't be serialized, there is where
tblib [0] comes handy.
[0]https://pypi.python.org/pypi/tblib
Regards,
Thanks, I wasn't aware of the multiprocessing.Queue workflow. It seems
like its going to require some changes in the actual code of the tasks
though. Did I get it right that I should stop raising exceptions then?
Something like:
def task_1(path, q):
# Do stuffs
if dont_work:
q.put(RuntimeError("didnt work"))
return
# finished
q.put(None)
return
Fabien
--
https://mail.python.org/mailman/listinfo/python-list