# How to iterate over a RemoteChannel?

**URL:** <https://discourse.julialang.org/t/how-to-iterate-over-a-remotechannel/24263>\
**Category:** General Usage\
**Created:** [May 15, 2019, 11:40pm UTC](https://discourse.julialang.org/t/how-to-iterate-over-a-remotechannel/24263 "2019-05-15T23:40:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonas-schulze](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jonas-schulze/32/9228_2.png) [@jonas-schulze](https://discourse.julialang.org/u/jonas-schulze)\
**Post date:** [May 15, 2019, 11:40pm UTC](https://discourse.julialang.org/t/how-to-iterate-over-a-remotechannel/24263/1 "2019-05-15T23:40:18Z")

</div>

For regular Channels `chan` it is ok to do

```julia
for val in chan
    @show val
end

```

but for a RemoteChannel there is no `iterate(::RemoteChannel)`. Is that one missing on purpose? What’s the proper way to spawn a task on a worker that processes all messages coming in via a RemoteChannel until it is closed?

---

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [May 16, 2019, 4:40am UTC](https://discourse.julialang.org/t/how-to-iterate-over-a-remotechannel/24263/2 "2019-05-16T04:40:03Z")

</div>

For reference: [https://github.com/JuliaLang/julia/issues/31177](https://github.com/JuliaLang/julia/issues/31177)

As an aside, I think iterating channels is slow because signalling of closed status is via exceptions, so iteration uses a try/catch approach. Perhaps it could be made more performant by returning closed status in some other way.
