Skip to content

asyncmap! encounters InvalidStateException: Channel is closed #47210

@kaandocal

Description

@kaandocal

This might be related to #35379. MWE:

output = []
asyncmap!(identity, output, 1:20)

This gives the following output:

ERROR: InvalidStateException: Channel is closed.
Stacktrace:
 [1] check_channel_state
   @ ./channels.jl:174 [inlined]
 [2] put!(c::Channel{Any}, v::Tuple{Int64, Tuple{Int64}})
   @ Base ./channels.jl:319
 [3] iterate(itr::Base.AsyncCollector, state::Base.AsyncCollectorState)
   @ Base ./asyncmap.jl:335
 [4] foreach
   @ ./abstractarray.jl:2774 [inlined]
 [5] #asyncmap!#954
   @ ./asyncmap.jl:405 [inlined]
 [6] asyncmap!(::Function, ::Vector{Any}, ::UnitRange{Int64})
   @ Base ./asyncmap.jl:404
 [7] top-level scope
   @ REPL[1]:1

Using asyncmap works fine. The error message is quite cryptic and does not explain the underlying problem (a mismatch between array sizes). In comparison, map! does not throw an error with the above code (it does not do anything).

Metadata

Metadata

Assignees

No one assigned

    Labels

    parallelismParallel or distributed computation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions