From 0d661b616080e521b0c35623142fc48ea27c37dd Mon Sep 17 00:00:00 2001 From: David Barsky Date: Tue, 17 Nov 2020 11:29:51 -0500 Subject: [PATCH] examples: fix echo example by reintroducing concurrency (#1107) --- examples/examples/echo.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/examples/echo.rs b/examples/examples/echo.rs index 3edd63cef4..24d5770d35 100644 --- a/examples/examples/echo.rs +++ b/examples/examples/echo.rs @@ -70,7 +70,7 @@ async fn main() -> Result<(), Box> { // Essentially here we're executing a new task to run concurrently, // which will allow all of our clients to be processed concurrently. - tokio::spawn(async move { + let fut = async move { let mut buf = [0; 1024]; // In a loop, read data from the socket and write the data back. @@ -115,8 +115,8 @@ async fn main() -> Result<(), Box> { info!(message = "echo'd data", %peer_addr, size = n); } - }) - .instrument(info_span!("echo", %peer_addr)) - .await?; + } + .instrument(info_span!("echo", %peer_addr)); + tokio::spawn(fut); } }