xtra: Handlers hang forever
Hello,
I have run into an issue in xtra
(via spaad
).
It may be my fault, but it’s not clear to me.
- I define a
Agent
actor, and make a publiclazy_static!
of it - I define
Config
actor, and make a publiclazy_static!
of it
This way anywhere in the application I can just send a message to the actors, it’s great. This may be the reason for my issue, idk.
So for example, in the new()
of Agent
:
#[spaad::entangled]
pub struct Agent {
my_state: HashMap<String, ConfigValue>
}
#[spaad::entangled]
impl Actor for Agent {}
#[spaad::entangled]
impl Agent {
#[spaad::spawn]
pub fn new() -> Self {
let c = futures::executor::block_on(CONFIG.get_config_value());
log::debug!("Got config: {:#?}", c);
Self {
// use config values to make my_state
my_state: { } // ...
}
}
// ...
}
where get_config_value
in this example is a handler.
We never reach Got config: ...
, shockingly we also never reach the inside of get_config_value
.
This is a contrived example, I had the same issue occur before where I was sending messages to the AGENT
lazy_static!
from a tokio task created with spawn
. I spent like a day trying to fix it, and then it began working, but I could not figure out exactly what made it work. I’m pretty sure I’m missing some big piece of information.
AGENT
can handle messages sent to it, however CONFIG
never can. They seem to be identical in implementation and instantiation. CONFIG
succeeds in being created, so it’s not like its waiting for the actor to come alive.
Any help would be great, thank you.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (7 by maintainers)
Could you show the lazy statics? Also, is it not more accurate to call this issue “spawns in spaad” hang forever, since it doesn’t even get to the
get_config_value
? I’ll look at this in the morning since it’s 1am right now in my timezone and I’m heading to bed, but I wonder if it can be reduced to a simplified reproducing example?