Sequence.Server's terminate handler
11 Feb 2014, 22:41
Chris Dawes (1 post)
Can I ask, is the terminate handler as implemented the recommended way to do things? While I was having a go at copying the changes across and testing with the Stack application, I was wondering how to simulate a process crash for testing.
raising an exception, or calling exit/1 inside a handle_cast or handle_call seems to do the right thing, and terminate is called.
calling Process.exit/2 from outside the process, with a reason of :normal seems to do nothing. I suppose that’s ok. calling it with a reason of :kill or anything else, crashes the process, but without running the terminate method.
could we add some more detail on how and why processes die? there’s already a section earlier in the book, but gen_server adds some extra details which I can’t find covered.
how would you fix the Sequence app to be more resilient in the face of people calling exit/2? would you bother fixing the Sequence app?
|You must be logged in to comment|