JuliaLang / Distributed.jl

Create and control multiple Julia processes remotely for distributed computing. Ships as a Julia stdlib.
https://docs.julialang.org/en/v1/stdlib/Distributed/
MIT License
20 stars 8 forks source link

Use `ExceptionStack` instead of `CapturedException` for Distributed and `asyncmap` #79

Open vchuravy opened 2 years ago

vchuravy commented 2 years ago

Could we potentially make use of the exception stack here now?

    catch
        close(chnl)
        retval = Base.ExceptionStack(Any[capture_exception(ex...) for ex in current_exceptions()])
    end

_Originally posted by @vtjnash in https://github.com/JuliaLang/julia/pull/42105#discussion_r780423800_

NHDaly commented 1 year ago

Excellent point Valentin. It seems like the ExceptionStack object itself isn't enough, since we probably want to have something that still <: Exception, so that it can e.g. be used to close(::Channel, ::Exception).

Would one of these two options make sense?:

  1. Introduce a new type, similar to CapturedException, which captures an entire catch stack? Like:
    • struct CapturedExceptionStackException <: Exception
         catch_stack::Vector{Any}
      end
      • (Clearly naming things is not my strong suit)
  2. Or, change the CapturedException implementation to hold a catch stack instead of the current exception + backtrace?
    • But i think this is probably a breaking change, and therefore not an acceptable option.

Maybe the name for the first one could be CapturedCatchStack <: Exception? Or CapturedExceptionStack <: Exception?

NHDaly commented 1 year ago

On the other hand, ideally the fields of a struct like this really shouldn't be part of the API of the stdlib. It shouldn't be a breaking change to change them, as long as we keep the existing method behaviors the same.. :/ But i know that this isn't the reality of how things work since julia doesn't have any encapsulation or private/public. :/

Do you have a preference here, @vchuravy?