A few remarks about actor and its supervisor in Actix
Actix has a supervisor that helps to restart an actor under its supervision. However, sometimes it doesn't. 😹
AFAIK something has to send a Die (message) to an actor when something went wrong. The actor has to implement a Die message handler. In the handler, it calls ctx.stop (context stop). When “Actor::stopping(...) == Running::Stop”, its poll function will return Poll::Ready. Then its supervisor can perform restarting.
In my case, all of these didn't work because of two reasons.
Actor didn't stop properly. It stopped without calling the stopped function. So I suppose it has no chance to handle the Die message.
Actor kept using the CPU when it went wrong. So the poll function was blocked. Then the actor cannot handle the Die message.
I fixed the first case by calling tokio::time::sleep, and the second case by breaking for the loop.
PS I'm not sure about what I wrote. Please tell me if I missed or misunderstood some things or even everything.