You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when running rewrk --json -t 12 -c 500 -d 30s -h http://127.0.0.1:3000 against this simplified version of the examples/async-h1-server (with tls removed):
use std::net::TcpListener;use anyhow::Result;use http_types::{Request,Response,StatusCode};use smol::Async;/// Serves a request and returns a response.asyncfnserve(_req:Request) -> http_types::Result<Response>{letmut res = Response::new(StatusCode::Ok);
res.insert_header("Content-Type","text/plain");
res.set_body("Hello, World!");Ok(res)}/// Listens for incoming connections and serves them.asyncfnlisten(listener:Async<TcpListener>) -> Result<()>{loop{// Accept the next connection.let(stream, _) = listener.accept().await?;// Spawn a background task serving this connection.let stream = async_dup::Arc::new(stream);let task = smol::spawn(asyncmove{ifletErr(err) = async_h1::accept(stream, serve).await{println!("Connection error: {:#?}", err);}});// Detach the task to let it run in the background.
task.detach();}}fnmain() -> Result<()>{// Start HTTP server.
smol::block_on(async{let http = listen(Async::<TcpListener>::bind(([127,0,0,1],3000))?);
http.await?;Ok(())})}
There are no build errors. We have found that if instead we use a smol::Executor these errors go away.
Specifically, replace:
let task = smol::spawn(asyncmove{ifletErr(err) = async_h1::accept(stream, serve).await{println!("Connection error: {:#?}", err);}});// Detach the task to let it run in the background.
task.detach();
with:
let ex = smol::Executor::new();
ex.spawn(asyncmove{ifletErr(err) = async_h1::accept(stream, serve).await{println!("Connection error: {:#?}", err);}}).detach();
We aren't sure if:
the example should just be updated,
we have used smol::spawn incorrectly
there is an issue with smol::spawn
The text was updated successfully, but these errors were encountered:
We observe a stream of these errors:
when running
rewrk --json -t 12 -c 500 -d 30s -h http://127.0.0.1:3000
against this simplified version of the examples/async-h1-server (with tls removed):There are no build errors. We have found that if instead we use a
smol::Executor
these errors go away.Specifically, replace:
with:
We aren't sure if:
smol::spawn
incorrectlysmol::spawn
The text was updated successfully, but these errors were encountered: