In these past few year I've found myself needing to execute several async tasks (mostly around getting remote resources) in scripts, and wanting to do something in the ones that fail
With the current implementation of async_stream, there is no way to know which ones failed, as the output would look like the following:
```
[1, 2, 3, 4]
|> Task.async_stream(
fn entry ->
if entry == 3, do: :timer.sleep(2000)
entry * entry
end,
timeout: 1000,
on_timeout: :exit_task
)
|> Enum.to_list()
[ok: 1, ok: 4, exit: :timeout, ok: 16]
```
That would force me to get creative with stream Zip, or hand roll my own solution.
Would you accept a PR about exposing this functionality again, but behind a opt-in new parameter that is false by default in order to keep backwards compatibility.
Using the previous example, it would look something like:
1, 2, 3, 4]
|> Task.async_stream(
...,
timeout: 1000,
on_timeout: :exit_task_with_value,
)
|> Enum.to_list()
[ok: 1, ok: 4, {:exit :timeout, 3}, ok: 16]
```
I'm not sold in the flag :exit_task_with_value, it could be a separate parameter as well, as long as it's opt_in
Thanks
______________________________________________________________
Juan -
No todo el oro reluce.....Ni todo errante anda perdido
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯