title: Elixir: rescue/catch task timeout
body: <p>I have the following code: </p>
  
  <pre><code>try do
    IO.inspect("start task")
    t = Task.async(fn -&gt; Process.sleep(7000)  end)
    IO.inspect("start awaiting")
    Task.await(t)
  rescue
    e -&gt;
      IO.inspect("catch error")
      IO.inspect(e)
  after
    IO.inspect("after")
  end
  IO.inspect("success ending")
  </code></pre>
  
  <p>That will print:</p>
  
  <pre><code>"start task"
  "start awaiting"
  "after"
  
  00:00:03.510 [info]  Application my_app exited: exited in: MyApp.Application.start(:normal, [])
  ** (EXIT) exited in: Task.await(%Task{owner: #PID&lt;0.497.0&gt;, pid: #PID&lt;0.498.0&gt;, ref: #Reference&lt;0.3923892342.570949633.190577&gt;}, 5000)
      ** (EXIT) time out
  </code></pre>
  
  <p>So await crashes my caller process, and I can't rescue the error, by somehow the "after" block is used. I don't understand how I can protect my caller process from a task timeout error.</p>