# Distributed.pgenerate not working as documented

**URL:** <https://discourse.julialang.org/t/distributed-pgenerate-not-working-as-documented/50615>\
**Category:** General Usage\
**Created:** [November 23, 2020, 6:28am UTC](https://discourse.julialang.org/t/distributed-pgenerate-not-working-as-documented/50615 "2020-11-23T06:28:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![marius311](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius311/32/3953_2.png) [@marius311](https://discourse.julialang.org/u/marius311)\
**Post date:** [November 23, 2020, 6:28am UTC](https://discourse.julialang.org/t/distributed-pgenerate-not-working-as-documented/50615/1 "2020-11-23T06:28:04Z")

</div>

The docstring for `Distributed.pgenerate` says

> Results are returned in order as they become available.

which is exactly what I need. However, it doesn’t seem to be working this way, instead, the results are only returned after all results have been calculated, e.g.:

```julia
julia> using Distributed

julia> addprocs(2)
2-element Array{Int64,1}:
 2
 3

julia> for i in Distributed.pgenerate(i->(sleep(0.5); println("Computed $i"); i), 1:4)
           println("Received $i")
       end
      From worker 2:	Computed 1
      From worker 3:	Computed 2
      From worker 2:	Computed 3
      From worker 3:	Computed 4
Received 1
Received 2
Received 3
Received 4

```

I was expecting to have seen “Received 1” and “Received 2” before 3 and 4 finished. Am I doing anything wrong, or is there some other way to achieve this? I’ve tried with Julia 1.3, 1.4, and 1.5.
