From 3e75043e742c6c5d77e02c3e72691fb49564b125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janosch=20Gr=C3=A4f?= Date: Tue, 9 Jul 2024 07:33:14 +0200 Subject: [PATCH] change example to use tokio::spawn again --- Cargo.toml | 2 +- examples/hello_world.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 984c01a..6d9366f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ web-sys = { version = "0.3", features = ["WebSocket", "CloseEvent", "ErrorEvent" wasm-bindgen-futures = "0.4" [dev-dependencies] -tokio = { version = "1", features = ["macros", "rt"] } +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } reqwest = { version = "0.12", features = ["default-tls"] } serde = { version = "1.0", features = ["derive"] } diff --git a/examples/hello_world.rs b/examples/hello_world.rs index 4e7b995..1ef89ab 100644 --- a/examples/hello_world.rs +++ b/examples/hello_world.rs @@ -2,7 +2,7 @@ use futures_util::{SinkExt, StreamExt, TryStreamExt}; use reqwest::Client; use reqwest_websocket::{Error, Message, RequestBuilderExt}; -#[tokio::main(flavor = "current_thread")] +#[tokio::main] async fn main() -> Result<(), Error> { let websocket = Client::default() .get("wss://echo.websocket.org/") @@ -14,7 +14,7 @@ async fn main() -> Result<(), Error> { let (mut tx, mut rx) = websocket.split(); - tokio::task::spawn_local(async move { + tokio::spawn(async move { for i in 1..11 { tx.send(Message::Text(format!("Hello, World! #{i}"))) .await