Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RemoteException not re-thrown by pmap() #12908

Closed
samoconnor opened this issue Sep 1, 2015 · 6 comments
Closed

RemoteException not re-thrown by pmap() #12908

samoconnor opened this issue Sep 1, 2015 · 6 comments
Labels
domain:error handling Handling of exceptions by Julia or the user domain:parallelism Parallel or distributed computation

Comments

@samoconnor
Copy link
Contributor

@everywhere function do_work(i)
    r = [1,2,3][i]
    println(r)
    return r
end

for r in pmap(do_work, [3,2,1,0])
    println("pmap got result")
    println(typeof(r))
end

The pmap() call above returns a RemoteException object in the result array instead of re-throwing it.

The output is:

./julia -p4 test.jl
    From worker 3:  2
    From worker 4:  1
    From worker 2:  3
pmap got result
Int64
pmap got result
Int64
pmap got result
Int64
pmap got result
RemoteException

Changing pmap() to map() results in BoundsError as expected.

@simonster
Copy link
Member

Related to/dup of #7808. Also IMO err_stop=true and rethrowing the error should be the default behavior for pmap.

@kshyatt kshyatt added domain:parallelism Parallel or distributed computation domain:error handling Handling of exceptions by Julia or the user labels Sep 1, 2015
@samoconnor
Copy link
Contributor Author

As far as I can tell err_stop=true is just a performance optimisation to save time when an error occurs.

However, re-throwing the exception (after re-tries) seems like a must unless the documentation clearly says that pmap() returns exceptions in the output collection.

@simonster
Copy link
Member

The problem is that there's no way to get the incomplete output of pmap if it throws an exception. If you set err_stop=err_rety=false, you clearly want the output even if it's incomplete. (With the defaults err_stop=false, err_retry=true it's a little less clear what you want.) The behavior should certainly be documented, but I imagine there are cases where it's desirable to return the exceptions instead of throwing them.

@samoconnor
Copy link
Contributor Author

To me it seems very clear: a function should either return a "complete" result or throw an exception.
A function that returns exception objects in-line with an output collection seems odd to me.

If "incomplete output of pmap" is useful in some particular application, that application could just do:

pmap([1,2,3]) do i
    try
        [1,2][i]
    catch e
        return e
    end
end

@simonster
Copy link
Member

But then failures never get retried with err_retry=true, because you don't throw an error.

samoconnor added a commit to samoconnor/julia that referenced this issue Sep 4, 2015
Interface

- Rethrow worker exception unless `err_stop == false` (fix JuliaLang#12908).
- Change err_retry from bool to int number of retries.
- Set defaults to `err_retry=0`, err_stop=true to match `map()`

Implementation

- Use `enumerate(zip(lsts...))` in place of `getnextidx()`,
  `states`, `nxtvals` etc to simplify iteration logic.
- Use `finally` to clear `busy_workers` flag.
samoconnor added a commit to samoconnor/julia that referenced this issue Sep 4, 2015
Interface

- Rethrow worker exception unless `err_stop == false` (fix JuliaLang#12908).
- Change err_retry from bool to int number of retries.
- Set defaults to `err_retry=0`, err_stop=true to match `map()`

Implementation

- Use `enumerate(zip(lsts...))` in place of `getnextidx()`,
  `states`, `nxtvals` etc to simplify iteration logic.
- Use `finally` to clear `busy_workers` flag.
@malmaud
Copy link
Contributor

malmaud commented Oct 14, 2015

This is definitely an issue, but closing in favor of the earlier #7808.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:error handling Handling of exceptions by Julia or the user domain:parallelism Parallel or distributed computation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants