# PMAP Throws Exception on ProcessExitedException

**URL:** https://discourse.julialang.org/t/pmap-throws-exception-on-processexitedexception/45667
**Category:** General Usage
**Tags:** question, pmap
**Created:** [August 28, 2020, 8:44am UTC](https://discourse.julialang.org/t/pmap-throws-exception-on-processexitedexception/45667 "2020-08-28T08:44:33Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Edward\_Wall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/edward_wall/32/9023_2.png) [@Edward\_Wall](https://discourse.julialang.org/u/Edward_Wall)
#### Post date: [August 28, 2020, 8:44am UTC](https://discourse.julialang.org/t/pmap-throws-exception-on-processexitedexception/45667/1 "2020-08-28T08:44:33Z")

</div>

A short question. Is there some way to use pmap such that the following doesn’t throw an exception and crash? I have a distributed system, where a process might use too much memory and be killed by the os. This seems to result in a ProcessExitedException and the entire program crashing. I am, however, okay with individual batches failing and would like the program to continue.

```julia
using Distributed

addprocs(3)

@everywhere function calc(i)

  val = mod(first(rand(Int, 1)), 4) + 1

  sleep(val)

  if myid() == 2 # Emulating Process Killed due to too much memory usage
    exit(1)
  end

  return i + val 

end

result = pmap(calc, vcat(1, workers());
              distributed=true,
              batch_size=1,
              retry_delays=[],
              retry_check=nothing,
              on_error=ex->-1
             )

print("Didn't crash")

```

---

<div class="post-metadata">

### Author: ![Edward\_Wall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/edward_wall/32/9023_2.png) [@Edward\_Wall](https://discourse.julialang.org/u/Edward_Wall)
#### Post date: [August 28, 2020, 9:13am UTC](https://discourse.julialang.org/t/pmap-throws-exception-on-processexitedexception/45667/2 "2020-08-28T09:13:40Z")

</div>

I suppose one would have to change this line in asyncmap.jl

[https://github.com/JuliaLang/julia/blob/4b42f1400a33d656ae9e61822b0a47b5cad7a777/base/asyncmap.jl#L177](https://github.com/JuliaLang/julia/blob/4b42f1400a33d656ae9e61822b0a47b5cad7a777/base/asyncmap.jl#L177)
