# Unhandled Task Error

**URL:** <https://discourse.julialang.org/t/unhandled-task-error/87749>\
**Category:** General Usage\
**Tags:** pmap, sharedarrays\
**Created:** [September 24, 2022, 3:51pm UTC](https://discourse.julialang.org/t/unhandled-task-error/87749 "2022-09-24T15:51:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jisutich](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jisutich/32/33342_2.png) [@jisutich](https://discourse.julialang.org/u/jisutich)\
**Post date:** [September 24, 2022, 3:51pm UTC](https://discourse.julialang.org/t/unhandled-task-error/87749/1 "2022-09-24T15:51:32Z")

</div>

Hi,

I am trying to use `pmap` to speed up my code. When I try to run a sample code with a for loop of just 10 cycles, I faced an unhandled task error. What does it mean?

 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/5/950d18bd5ca917727811bc54a79c1f9472e8df14.png)

Personally I think the 10 cycles have finished since I ask code to print the time when a cycle finishes. But the rest of code is just to save the data to a .jld file. Why do I get this error?

Thanks

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [September 24, 2022, 9:44pm UTC](https://discourse.julialang.org/t/unhandled-task-error/87749/2 "2022-09-24T21:44:07Z")

</div>

I think `ProcessExitedException` is the bit to look for here; that means the worker process exited. Could be it ran out of memory and the OS killed it.

---

<div class="post-metadata">

**Author:** ![jisutich](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jisutich/32/33342_2.png) [@jisutich](https://discourse.julialang.org/u/jisutich)\
**Post date:** [September 24, 2022, 11:13pm UTC](https://discourse.julialang.org/t/unhandled-task-error/87749/3 "2022-09-24T23:13:34Z")

</div>

Hi Eric:

It turns out this error is due to one sentence like

```julia
@distributed for i = 1:length(pool)
pool[i] = a[i]
end

```

Here `pool` is a `SharedArray`. And `a` is a normal vector. After I changed it to be

```julia
for i = 1:length(pool)
pool[i] = a[i]
end

```

The problem disappeared. But I don’t know why. It just works.
