pouhong

pouhong

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

Most Liked

peerreynders

peerreynders

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.

Where Next?

Popular in Questions Top

ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49134 226
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New

We're in Beta

About us Mission Statement