Is it considered bad form to spawn a process and never send/receive?

Up until now, I’ve used spawn along with send and receive – this works well for things like parallel fetching of multiple URLs simultaneously.

Forgive me: concurrency is not something I’m an expert at, but is it considered bad form to spawn a process and not send or receive messages?

My specific use case is that I want to paginate through a bunch of database records, say 50 or 100 at a time. The only calculation that is immediately necessary is calculating the next database query (by increasing the offset parameter). The processing of this data could all be done async via a separate thread, but since the result of the data is always a side effect (like writing data to a file or inserting another database record), I don’t need to use Enum.map to associate caller PIDs with received messages. Is that normal to sort of “throw away” a process by ignoring any value it sends back? Now that I think about it, I could have structured my parallel URL scraping in this way: instead of receiving a response, I could have just written data to a database etc. in the separate thread. Right? Would that be a bad pattern?

Thanks for the guidance.

2 Likes

It is totally fine to use a process just for side effects and not communicate with it. Thats basically what Task.start_link is for. :slight_smile:

4 Likes