Skip to content

Multiple error handling #5

@YoungFaithful

Description

@YoungFaithful

Multiple error handling of a spawned task is currently sub optimal:

  • The first error returns a failed task, but breaks the WorkerUtilities
  • The second error is just a runnable task.
    How could we assign the error to the task and finish the task?
julia -t 2
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.5.3 (2020-11-09)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using WorkerUtilities

julia> WorkerUtilities.init()

julia> resp = WorkerUtilities.@spawn(sqrt(-1))
Task (failed) @0x00007f96267c5120
DomainError with -1.0:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:33
sqrt at ./math.jl:573 [inlined]
sqrt(::Int64) at ./math.jl:599
(::var"#1#2")() at ./task.jl:112

julia> resp
Task (failed) @0x00007f96267c5120
DomainError with -1.0:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:33
sqrt at ./math.jl:573 [inlined]
sqrt(::Int64) at ./math.jl:599
(::var"#1#2")() at ./task.jl:112

julia> resp = WorkerUtilities.@spawn(sqrt(-2))
# Takes forever...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions