-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PgListener causes a panic on-drop in async fn main()
#1389
Comments
I think I understand why this is happening and it doesn't have anything to do with the The issue is that However, that task contains a Unfortunately the fix for this would be However, another potential fix is to not spawn a task in the Alternatively, we could inline the async code from In the meantime, what should prevent this panic from happening is calling #[derive(actix::Message)]
#[rtype("()")]
struct StopMessage;
impl Handler<StopMessage> for ListenerActor {
fn handle(&mut self, _: StopMessage, ctx: &mut Context<Self>) -> () {
ctx.stop();
}
}
// then in `main()`
let addr = ListenerActor::create(|ctx| ...);
actix_rt::signal::ctrl_c().await;
addr.send(StopMessage).await?;
pool.close().await?;
Ok(()) |
PgListener::drop()
PgListener::drop()
async fn main()
Thank's for this explanation ! Could we have the Anyway in my use case I can't send a How can we iterate over a solution for this bug tho? |
I've opened #1393 with a fix, I forgot |
Hello and thank's for this PR. Anyway, I tried with master and I keep having the same error when kill the application. |
@abonander I proposed a new update on the |
I think #1395 is what did it for me. Just tried with git/main and error is gone. Could it be released please? |
Hello @cortopy I think it will be released in the next minor sooner :) Tell me if I'm wrong @abonander ! |
Hello,
I ran into an issue with SQLx
PgListener
when using it withActix
stream.Everything works fine unless I
CtrlC
my application. When killing the application I expect that the application stops without panicking, but I'm facing some weirdthread 'main' panicked at 'there is no reactor running, must be called from the context of a Tokio 1.x runtime'
.When my actor gets dropped he drop the listener stream which execute the drop method on the PgListener.
I suppose that the panic is due to the sqlx_rt trying to execute something on an already closed system.
I'm using
rustc 1.54.0
, SQLXmaster - 207e6db2
, actix0.12.0
.I've update the Postgres listen example on my fork to allow anyone to reproduce: https://github.com/Freyskeyd/sqlx/tree/crash_ctrlc/examples/postgres/listen
here's the panic:
Feel free to ask for more details if needed !
Thank's a lot !
The text was updated successfully, but these errors were encountered: