sysashi
I have a gen server spawned by simple one for one supervisor, and when I return {:stop, {:shutdown, reason}, state} process remains alive, even though terminate/2 callback is called. What am I doing wrong? (if instead of returning :stop tuple I call Supervisor.terminate_child(MySupervisor, self()) process terminates as expected. How do I stop it, and what is the right way?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
I think I’ve found a small improvement I could contribute to <%= web_namespace %>.CoreComponents (installer/templates/phx_web/compo...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #elixirconf-us
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
idi527
Does it actually remain alive (same pid), or does it get restarted?
sysashi
It remains alive and not restarted
dom
terminate/2 could be hanging. If you do Process.info() after the pid tried to stop, what does the backtrace look like?
kokolegorille
Is it a call or a cast? I remember having some troubles with the response tupple. Maybe try to change your return value.
There is a call return
There is a cast return
BTW simple_one_for_one is going to be deprecated in favor of Dynamic Supervisor. I also had syntax problem, dialyzer warning because of it. simple_one_for_one does not accept new child_spec.
sysashi
looks like ```
[current_function: {:gen_server, :loop, 7},
initial_call: {:proc_lib, :init_p, 5}, status: :waiting, message_queue_len: 0,
messages: , links: [pid<0.472.0>],
dictionary: [“$initial_call”: {Manager, :init, 1},
“$ancestors”: [ManagerSupervisor,
PipelineSupervisor, MySupervisor, pid<0.456.0>]],
trap_exit: false, error_handler: :error_handler, priority: :normal,
group_leader: pid<0.455.0>, total_heap_size: 233, heap_size: 233,
stack_size: 10, reductions: 45,
garbage_collection: [max_heap_size: %{error_logger: true, kill: true, size: 0},
min_bin_vheap_size: 46422, min_heap_size: 233, fullsweep_after: 65535,
minor_gcs: 0], suspending: ]
sysashi
I have both callbacks, when I need to stop on call I do
{:stop, :shutdown, reply, state}on casts I do{:stop, :shutdown, state}Yeah, I have a lot of stuff to migrate to Dynamic Supervisor
dom
It’s not possible for a gen_server to go back to loop after terminate is called. Are you really sure terminate was called, and the process wasn’t restarted?
NobbZ
How was the child initialised? What’s it restart value? Permanent, temporary or transient?
sysashi
I’m sorry I’ve wasted your time folks, process is being restarted (Initially I’ve checked the state of the process, and for my surprise state remained from the previous process, so I thought it’s the same one, next I checked observer to verify that pid does not change and it’s the same process, but it actually has changed and new pid was a digit different from the previous one so I did not notice at first…
)
Later I set restart to
temporaryand it worked as intended (as @NobbZ pointed out).One question though, does supervisor keeps initial state of the process? Because said process being restarted with the same state I initialised the previous one.
dom
It doesn’t keep state, but it uses the same start function and arguments, so if your initialization is deterministic the process will end up in the same state.