Warning
This post was published 114 days ago. The information described in this article may have changed.
Actix processes blocking request handlers blockingly if I send them from different tabs in the same browser, but seems doesn't block across two different browsers.
What I do is send get requests from Chrome to block_me
from adjacent tabs versus one request from Chrome and one from Firefox.
Is this because a new session means a new worker is spawned? If so will it start blocking if I exceed available_parallelism
? Thanks.
use actix_web::{web, App, HttpResponse, HttpServer, Responder};
async fn blocking_handler() -> impl Responder {
println!("blocking request received");
std::thread::sleep(std::time::Duration::from_secs(10));
"Blocking handler finally returns"
}
async fn non_blocking_handler() -> impl Responder {
println!("NON blocking request received");
tokio::time::sleep(std::time::Duration::from_secs(10)).await;
"NON-Blocking handler finally returns"
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(||
App::new()
.route("/", web::get().to(HttpResponse::Ok))
.route("/block_me", web::get().to(blocking_handler))
.route("/non_block_me", web::get().to(non_blocking_handler))
)
.bind(("127.0.0.1", 9090))?
.run()
.await
}
5 posts - 3 participants
🏷️ rust_feed