Skip to content

"spawn_local" panic when using Actors within Actix in a sqlx::test runtime #2105

Answered by abonander
esmevane asked this question in Q&A
Discussion options

You must be logged in to vote

#[sqlx::test] doesn't start an actix_rt::System. The runtime-actix features were changed to aliases of the runtime-tokio features, actually by a PR from @robjtede in #1679, because actix-web is meant to be fully compatible with Tokio now.

You can probably start your actor from within the closure passed to HttpServer::new() as I'd expect that to be run on each worker thread when it starts. If you only want it to be run once you could protect that with a std::sync::Once or a simple AtomicBool in a static.

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@esmevane
Comment options

Answer selected by esmevane
Comment options

You must be logged in to vote
5 replies
@robjtede
Comment options

@esmevane
Comment options

@tolumide-ng
Comment options

@abonander
Comment options

@tolumide-ng
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants