I’m doing a 7-part screencast that deep-dives into how Elixir (yup, that’s elixir, not erlang) does processes.
Prerequisites are understanding Elixir syntax, content ranges from beginner to “ready to become and advanced Elixir programmer”.
I’m doing a 7-part screencast that deep-dives into how Elixir (yup, that’s elixir, not erlang) does processes.
Prerequisites are understanding Elixir syntax, content ranges from beginner to “ready to become and advanced Elixir programmer”.
Amazing introduction.
I really like the way you explain things.
keep up the good work, looking forward to the next video.
great content btw, really helped me deep dive into processes
Amazing series! Can’t wait for the following episodes.
I love it! And I did learn something from the series. Thank you.
This is awesome! Thank you!
However, I noticed that it’s recommended to run tasks under Task.Supervisor… But in that case looks like it loses $callers
and Mox fails to define an expectation in the caller’s process and I have to :set_mox_global
and forget about running tests with async: true
Any suggestion?
Haha you got ahead of me I will address that my solution is that Elixir Std Lib should support that out of the box (and it would also be nice to have GenServers forward callers via an option too). If you absolutely must have a solution, I wrote this library: Multiverses.DynamicSupervisor — multiverses v0.7.0
Note that a Task.Supervisor is actually a DynamicSupervisor
Hm. I took a second look at it and Task.Supervisor.start_child should be setting callers correctly:
Not wanting to hijack the post, but if I am not in mistake @josevalim said once that most probably we wouldn’t have an Elixir V2.0, but after all it seems to be planned one???
There are a bunch of those comments in elixir core, but I guess not because it’s planed, but because it’s useful if it eventually becomes an option.
Huh, right! Thank you for clarifying! Tried on simple example it worked as expected!
In the project I’m working on turned out the issue was in a different module where async processing is implemented via GenServer handle_info
… I misread the error message
Thank you for bringing it up here!
I just replaced stateless GenServers with supervised tasks and tested with Mox with async: true
(yay!)
Each time someone changes a linear-flow GenServer to a Task, an angel gets their wings lol.
I heard that some part of the Phoenix framework is some processes that are not GenServers but still can be supervised by a supervisor. I wonder what’s the minimal requirement to make a process that can be supervised.
There are many non GenServer processes, which can be supervised: Task
, :gen_statem
and some other :gen_*
behaviours. Basically there are plain processes, which are just barebone, then there are processes spawned by :proc_lib
, which also adhere to OTP design principles and then there are higher level abstractions and behaviours, which often use :proc_lib
internally. Those last ones are the tasks, genservers, statemachines, ….
Then how many messages should a process be able to handle so that it can be supervised? None?
Also, what messages should a supervised process be able to spit out? On what condition?
Those things are afaik documented in the docs for :proc_lib
/:sys
, like here:
Not sure if there’s more, I never did a deep dive into the topic.
Thanks a lot for the documentation. That’s fascinating. I’ll give it a shot (in Elixir, of course) this weekend.