Spawn multiple threads and block/join

This is probably a basic question explained by my newness to Elixir and the OTP and supervisor, so forgive me and inb4 “rtfm” - your answer to this question will help me know where to start reading.

If I wanted to launch a bunch of tasks - for the sake of argument let’s say each will do an HTTP request and do something with the response - and then block/join on all of them and collect the results and do something with it, what would I use for that? I’m a bit overwhelmed right now looking at the various levels and techniques of async.

If any of the spawned tasks crashes catastrophically, I’d like to be able to note that fact and maybe deal with it in my final computation but I would not want it to crash the entire process.

Thanks

That’s kind of a use case for Task.Supervisor.async_stream_nolink/4 - but that involves a number of BEAM concepts.

Should really start with: Processes, Supervisor and Application.

Contrived example and brief explanation.

1 Like