diff --git a/Cargo.lock b/Cargo.lock index 378605fc3..a654ac996 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,7 +164,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b894941f818cfdc7ccc4b9e60fa7e53b5042a2e8567270f9147d5591893373a" dependencies = [ "futures-core", - "paste 1.0.7", + "paste", "pin-project-lite", ] @@ -460,16 +460,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "ctor" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f877be4f7c9f246b183111634f75baa039715e3f46ce860677d3b19a69fb229c" -dependencies = [ - "quote", - "syn", -] - [[package]] name = "dashmap" version = "4.0.2" @@ -656,17 +646,6 @@ dependencies = [ "wasi 0.10.2+wasi-snapshot-preview1", ] -[[package]] -name = "ghost" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c813ffb63e8fd3df6f1ac3cc1ea392c7612ac2de4d0b44dcbfe03e5c4bf94a" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "h2" version = "0.3.13" @@ -753,26 +732,9 @@ dependencies = [ [[package]] name = "indoc" -version = "0.3.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47741a8bc60fb26eb8d6e0238bbb26d8575ff623fdc97b1a2c00c050b9684ed8" -dependencies = [ - "indoc-impl", - "proc-macro-hack", -] - -[[package]] -name = "indoc-impl" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce046d161f000fffde5f432a0d034d0341dc152643b2598ed5bfce44c4f3a8f0" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "syn", - "unindent", -] +checksum = "adab1eaa3408fb7f0c777a73e7465fd5656136fc93b670eb6df3c88c2c1344e3" [[package]] name = "instant" @@ -783,28 +745,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "inventory" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb5160c60ba1e809707918ee329adb99d222888155835c6feedba19f6c3fd4" -dependencies = [ - "ctor", - "ghost", - "inventory-impl", -] - -[[package]] -name = "inventory-impl" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e41b53715c6f0c4be49510bb82dee2c1e51c8586d885abe65396e82ed518548" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "io-uring" version = "0.5.2" @@ -893,9 +833,9 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] name = "matchit" -version = "0.4.6" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9376a4f0340565ad675d11fc1419227faf5f60cd7ac9cb2e7185a471f30af833" +checksum = "3dfc802da7b1cf80aefffa0c7b2f77247c8b32206cc83c270b61264f5b360a80" [[package]] name = "memchr" @@ -903,6 +843,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + [[package]] name = "mime" version = "0.3.16" @@ -961,9 +910,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.10.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" +checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" [[package]] name = "parking_lot" @@ -1013,31 +962,12 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "paste" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" -dependencies = [ - "paste-impl", - "proc-macro-hack", -] - [[package]] name = "paste" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" -[[package]] -name = "paste-impl" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" -dependencies = [ - "proc-macro-hack", -] - [[package]] name = "percent-encoding" version = "2.1.0" @@ -1062,12 +992,6 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - [[package]] name = "proc-macro2" version = "1.0.38" @@ -1079,28 +1003,28 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.14.5" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35100f9347670a566a67aa623369293703322bb9db77d99d7df7313b575ae0c8" +checksum = "201b6887e5576bf2f945fe65172c1fcbf3fcf285b23e4d71eb171d9736e38d32" dependencies = [ "cfg-if", "indoc", "libc", - "parking_lot 0.11.2", - "paste 0.1.18", + "memoffset", + "parking_lot 0.12.0", "pyo3-build-config", + "pyo3-ffi", "pyo3-macros", "unindent", ] [[package]] name = "pyo3-asyncio" -version = "0.14.1" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c1305dd07022dff29a85b0a9fcf414bee3139d35730acd4d0268b352c02e57" +checksum = "1febe3946b26194628f00526929ee6f8559f9e807f811257e94d4c456103be0e" dependencies = [ "futures", - "inventory", "once_cell", "pin-project-lite", "pyo3", @@ -1110,9 +1034,9 @@ dependencies = [ [[package]] name = "pyo3-asyncio-macros" -version = "0.14.1" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a93d8c020d68356d2ecb36b3462529f38e7b87ca6c54d2a8cc5479fb731e699" +checksum = "270b167ea304b961616aa0f003463c95becd3c11a85bd83ba668fe16129e2469" dependencies = [ "proc-macro2", "quote", @@ -1121,18 +1045,29 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.14.5" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d12961738cacbd7f91b7c43bc25cfeeaa2698ad07a04b3be0aa88b950865738f" +checksum = "bf0708c9ed01692635cbf056e286008e5a2927ab1a5e48cdd3aeb1ba5a6fef47" dependencies = [ "once_cell", + "target-lexicon", +] + +[[package]] +name = "pyo3-ffi" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90352dea4f486932b72ddf776264d293f85b79a1d214de1d023927b41461132d" +dependencies = [ + "libc", + "pyo3-build-config", ] [[package]] name = "pyo3-log" -version = "0.4.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6087e5025c5d7d6ed6294c68f83d9f7965c2b3fd3a726ecc1c22dbe4af7390f4" +checksum = "e5695ccff5060c13ca1751cf8c857a12da9b0bf0378cb071c5e0326f7c7e4c1b" dependencies = [ "arc-swap", "log", @@ -1141,10 +1076,11 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.14.5" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0bc5215d704824dfddddc03f93cb572e1155c68b6761c37005e1c288808ea8" +checksum = "7eb24b804a2d9e88bfcc480a5a6dd76f006c1e3edaf064e8250423336e2cd79d" dependencies = [ + "proc-macro2", "pyo3-macros-backend", "quote", "syn", @@ -1152,12 +1088,11 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.14.5" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71623fc593224afaab918aa3afcaf86ed2f43d34f6afde7f3922608f253240df" +checksum = "f22bb49f6a7348c253d7ac67a6875f2dc65f36c2ae64a82c381d528972bea6d6" dependencies = [ "proc-macro2", - "pyo3-build-config", "quote", "syn", ] @@ -1367,6 +1302,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "target-lexicon" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c02424087780c9b71cc96799eaeddff35af2bc513278cda5c99fc1f5d026d3c1" + [[package]] name = "time" version = "0.3.9" @@ -1548,9 +1489,9 @@ dependencies = [ [[package]] name = "uuid" -version = "0.8.2" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" dependencies = [ "getrandom", "serde", diff --git a/Cargo.toml b/Cargo.toml index eb7dd96d6..ac7f2aab5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,27 +14,27 @@ name = "robyn" crate-type = ["cdylib", "rlib"] [dependencies.pyo3] -version = "0.14.1" +version = "0.17.2" features = ["extension-module"] [dependencies] tokio = { version = "1.7.0", features = ["full"] } dashmap = {git = "https://github.com/quake/dashmap", branch = "parking_lot", features = ["parking_lot"]} -pyo3-asyncio = { version="0.14.0" , features = ["attributes", "tokio-runtime"] } +pyo3-asyncio = { version="0.17.0" , features = ["attributes", "tokio-runtime"] } anyhow = "1.0.38" actix-web = "4.0.1" actix-files = "0.6.0" futures-util = "0.3.15" -matchit = "0.4.3" +matchit = "0.6.0" actix-http = "3.0.4" socket2 = { version = "0.4.1", features = ["all"] } actix = "0.13.0" actix-web-actors = "4.1.0" -uuid = { version = "0.8", features = ["serde", "v4"] } +uuid = { version = "1.2.1", features = ["serde", "v4"] } serde = "1.0.136" serde_json = "1.0.79" futures = "0.3.21" -pyo3-log = "0.4.1" +pyo3-log = "0.7.0" log = "0.4.17" [features] diff --git a/src/executors/mod.rs b/src/executors/mod.rs index a03d3e43d..16ab12686 100644 --- a/src/executors/mod.rs +++ b/src/executors/mod.rs @@ -8,12 +8,11 @@ use std::collections::HashMap; use std::rc::Rc; use std::sync::Arc; - use actix_web::HttpResponse; - -use actix_web::{ HttpRequest}; -use anyhow::{ Result}; +use actix_web::{http::Method, web, HttpRequest}; +use anyhow::{bail, Result}; use log::{debug, info}; +use pyo3_asyncio::TaskLocals; // pyO3 module use crate::types::PyFunction; @@ -306,7 +305,7 @@ pub async fn execute_http_function( pub async fn execute_event_handler( event_handler: Option>, - event_loop: Arc>, + task_locals: &TaskLocals, ) -> Result<(), Box> { if let Some(handler) = event_handler { match &(*handler) { @@ -322,8 +321,8 @@ pub async fn execute_event_handler( debug!("Startup event handler async"); let coroutine = function.as_ref(py).call0().unwrap(); - pyo3_asyncio::into_future_with_loop((*event_loop).as_ref(py), coroutine) - .unwrap() + + pyo3_asyncio::into_future_with_locals(task_locals, coroutine).unwrap() }); future.await?; } diff --git a/src/routers/const_router.rs b/src/routers/const_router.rs index 675324424..f8f65bb7e 100644 --- a/src/routers/const_router.rs +++ b/src/routers/const_router.rs @@ -7,41 +7,41 @@ use pyo3::prelude::*; use pyo3::types::PyAny; use actix_web::http::Method; -use matchit::Node; +use matchit::Router; use anyhow::{bail, Error, Result}; /// Contains the thread safe hashmaps of different routes pub struct ConstRouter { - get_routes: Arc>>, - post_routes: Arc>>, - put_routes: Arc>>, - delete_routes: Arc>>, - patch_routes: Arc>>, - head_routes: Arc>>, - options_routes: Arc>>, - connect_routes: Arc>>, - trace_routes: Arc>>, + get_routes: Arc>>, + post_routes: Arc>>, + put_routes: Arc>>, + delete_routes: Arc>>, + patch_routes: Arc>>, + head_routes: Arc>>, + options_routes: Arc>>, + connect_routes: Arc>>, + trace_routes: Arc>>, } impl ConstRouter { pub fn new() -> Self { Self { - get_routes: Arc::new(RwLock::new(Node::new())), - post_routes: Arc::new(RwLock::new(Node::new())), - put_routes: Arc::new(RwLock::new(Node::new())), - delete_routes: Arc::new(RwLock::new(Node::new())), - patch_routes: Arc::new(RwLock::new(Node::new())), - head_routes: Arc::new(RwLock::new(Node::new())), - options_routes: Arc::new(RwLock::new(Node::new())), - connect_routes: Arc::new(RwLock::new(Node::new())), - trace_routes: Arc::new(RwLock::new(Node::new())), + get_routes: Arc::new(RwLock::new(Router::new())), + post_routes: Arc::new(RwLock::new(Router::new())), + put_routes: Arc::new(RwLock::new(Router::new())), + delete_routes: Arc::new(RwLock::new(Router::new())), + patch_routes: Arc::new(RwLock::new(Router::new())), + head_routes: Arc::new(RwLock::new(Router::new())), + options_routes: Arc::new(RwLock::new(Router::new())), + connect_routes: Arc::new(RwLock::new(Router::new())), + trace_routes: Arc::new(RwLock::new(Router::new())), } } #[inline] - fn get_relevant_map(&self, route: Method) -> Option>>> { + fn get_relevant_map(&self, route: Method) -> Option>>> { match route { Method::GET => Some(self.get_routes.clone()), Method::POST => Some(self.post_routes.clone()), @@ -57,7 +57,7 @@ impl ConstRouter { } #[inline] - fn get_relevant_map_str(&self, route: &str) -> Option>>> { + fn get_relevant_map_str(&self, route: &str) -> Option>>> { if route != "WS" { let method = match Method::from_bytes(route.as_bytes()) { Ok(res) => res, diff --git a/src/routers/middleware_router.rs b/src/routers/middleware_router.rs index 1f609f818..9ed26c708 100644 --- a/src/routers/middleware_router.rs +++ b/src/routers/middleware_router.rs @@ -5,27 +5,27 @@ use crate::types::PyFunction; use pyo3::prelude::*; use pyo3::types::PyAny; -use matchit::Node; +use matchit::Router; use anyhow::{bail, Error, Result}; /// Contains the thread safe hashmaps of different routes pub struct MiddlewareRouter { - before_request: RwLock>, - after_request: RwLock>, + before_request: RwLock>, + after_request: RwLock>, } impl MiddlewareRouter { pub fn new() -> Self { Self { - before_request: RwLock::new(Node::new()), - after_request: RwLock::new(Node::new()), + before_request: RwLock::new(Router::new()), + after_request: RwLock::new(Router::new()), } } #[inline] - fn get_relevant_map(&self, route: &str) -> Option<&RwLock>> { + fn get_relevant_map(&self, route: &str) -> Option<&RwLock>> { match route { "BEFORE_REQUEST" => Some(&self.before_request), "AFTER_REQUEST" => Some(&self.after_request), diff --git a/src/routers/router.rs b/src/routers/router.rs index b75aef09d..dcf9cb904 100644 --- a/src/routers/router.rs +++ b/src/routers/router.rs @@ -6,41 +6,41 @@ use pyo3::prelude::*; use pyo3::types::PyAny; use actix_web::http::Method; -use matchit::Node; +use matchit::Router as MatchItRouter; use anyhow::{bail, Error, Result}; /// Contains the thread safe hashmaps of different routes pub struct Router { - get_routes: RwLock>, - post_routes: RwLock>, - put_routes: RwLock>, - delete_routes: RwLock>, - patch_routes: RwLock>, - head_routes: RwLock>, - options_routes: RwLock>, - connect_routes: RwLock>, - trace_routes: RwLock>, + get_routes: RwLock>, + post_routes: RwLock>, + put_routes: RwLock>, + delete_routes: RwLock>, + patch_routes: RwLock>, + head_routes: RwLock>, + options_routes: RwLock>, + connect_routes: RwLock>, + trace_routes: RwLock>, } impl Router { pub fn new() -> Self { Self { - get_routes: RwLock::new(Node::new()), - post_routes: RwLock::new(Node::new()), - put_routes: RwLock::new(Node::new()), - delete_routes: RwLock::new(Node::new()), - patch_routes: RwLock::new(Node::new()), - head_routes: RwLock::new(Node::new()), - options_routes: RwLock::new(Node::new()), - connect_routes: RwLock::new(Node::new()), - trace_routes: RwLock::new(Node::new()), + get_routes: RwLock::new(MatchItRouter::new()), + post_routes: RwLock::new(MatchItRouter::new()), + put_routes: RwLock::new(MatchItRouter::new()), + delete_routes: RwLock::new(MatchItRouter::new()), + patch_routes: RwLock::new(MatchItRouter::new()), + head_routes: RwLock::new(MatchItRouter::new()), + options_routes: RwLock::new(MatchItRouter::new()), + connect_routes: RwLock::new(MatchItRouter::new()), + trace_routes: RwLock::new(MatchItRouter::new()), } } #[inline] - fn get_relevant_map(&self, route: Method) -> Option<&RwLock>> { + fn get_relevant_map(&self, route: Method) -> Option<&RwLock>> { match route { Method::GET => Some(&self.get_routes), Method::POST => Some(&self.post_routes), @@ -56,7 +56,10 @@ impl Router { } #[inline] - fn get_relevant_map_str(&self, route: &str) -> Option<&RwLock>> { + fn get_relevant_map_str( + &self, + route: &str, + ) -> Option<&RwLock>> { if route != "WS" { let method = match Method::from_bytes(route.as_bytes()) { Ok(res) => res, diff --git a/src/server.rs b/src/server.rs index 11e62461f..68d50c8c5 100644 --- a/src/server.rs +++ b/src/server.rs @@ -103,23 +103,23 @@ impl Server { asyncio .call_method1("set_event_loop", (event_loop,)) .unwrap(); - let event_loop_hdl = Arc::new(PyObject::from(event_loop)); - let event_loop_cleanup = event_loop_hdl.clone(); let startup_handler = self.startup_handler.clone(); let shutdown_handler = self.shutdown_handler.clone(); + let task_locals = Arc::new(pyo3_asyncio::TaskLocals::new(event_loop).copy_context(py)?); + let task_locals_cleanup = task_locals.clone(); + thread::spawn(move || { - //init_current_thread_once(); - let copied_event_loop = event_loop_hdl.clone(); actix_web::rt::System::new().block_on(async move { debug!("The number of workers are {}", workers.clone()); - execute_event_handler(startup_handler, copied_event_loop.clone()) + execute_event_handler(startup_handler, &task_locals) .await .unwrap(); HttpServer::new(move || { let mut app = App::new(); - let event_loop_hdl = copied_event_loop.clone(); + + let task_locals = task_locals.clone(); let directories = directories.read().unwrap(); // this loop matches three types of directory serving @@ -155,7 +155,7 @@ impl Server { for (elem, value) in (web_socket_map.read().unwrap()).iter() { let route = elem.clone(); let params = value.clone(); - let event_loop_hdl = event_loop_hdl.clone(); + let task_locals = task_locals.clone(); app = app.route( &route.clone(), web::get().to( @@ -167,7 +167,7 @@ impl Server { req, stream, params.clone(), - event_loop_hdl.clone(), + task_locals.clone(), ) }, ), @@ -181,20 +181,17 @@ impl Server { global_headers, payload, req| { - pyo3_asyncio::tokio::scope_local( - (*event_loop_hdl).clone(), - async move { - index( - router, - const_router, - middleware_router, - global_headers, - payload, - req, - ) - .await - }, - ) + pyo3_asyncio::tokio::scope_local((*task_locals).clone(), async move { + index( + router, + const_router, + middleware_router, + global_headers, + payload, + req, + ) + .await + }) }, )) }) @@ -213,9 +210,8 @@ impl Server { if event_loop.is_err() { debug!("Ctrl c handler"); Python::with_gil(|py| { - let event_loop_hdl = event_loop_cleanup.clone(); pyo3_asyncio::tokio::run(py, async move { - execute_event_handler(shutdown_handler, event_loop_hdl.clone()) + execute_event_handler(shutdown_handler, &task_locals_cleanup) .await .unwrap(); Ok(()) @@ -497,7 +493,9 @@ async fn index( } }; - if let Some(((handler_function, number_of_params), route_params)) = middleware_router.get_route("AFTER_REQUEST", req.uri().path()) { + if let Some(((handler_function, number_of_params), route_params)) = + middleware_router.get_route("AFTER_REQUEST", req.uri().path()) + { let x = handle_http_middleware_request( handler_function, number_of_params, diff --git a/src/web_socket_connection.rs b/src/web_socket_connection.rs index cd939839b..437bbe96c 100644 --- a/src/web_socket_connection.rs +++ b/src/web_socket_connection.rs @@ -7,6 +7,7 @@ use actix_web_actors::ws; use actix_web_actors::ws::WebsocketContext; use log::debug; use pyo3::prelude::*; +use pyo3_asyncio::TaskLocals; use uuid::Uuid; use std::collections::HashMap; @@ -19,13 +20,13 @@ struct MyWs { router: HashMap, // can probably try removing arc from here // and use clone_ref() - event_loop: Arc, + task_locals: Arc, } fn execute_ws_function( handler_function: &PyFunction, number_of_params: u8, - event_loop: Arc, + task_locals: &TaskLocals, ctx: &mut ws::WebsocketContext, ws: &MyWs, // add number of params here @@ -53,8 +54,7 @@ fn execute_ws_function( // this is done to accomodate any future params 2_u8..=u8::MAX => handler.call1((ws.id.to_string(),)).unwrap(), }; - pyo3_asyncio::into_future_with_loop((*(event_loop.clone())).as_ref(py), coro) - .unwrap() + pyo3_asyncio::into_future_with_locals(task_locals, coro).unwrap() }); let f = async move { let output = fut.await.unwrap(); @@ -81,7 +81,7 @@ impl Actor for MyWs { execute_ws_function( handler_function, *number_of_params, - self.event_loop.clone(), + &self.task_locals, ctx, self, ); @@ -95,7 +95,7 @@ impl Actor for MyWs { execute_ws_function( handler_function, *number_of_params, - self.event_loop.clone(), + &self.task_locals, ctx, self, ); @@ -120,7 +120,7 @@ impl StreamHandler> for MyWs { execute_ws_function( handler_function, *number_of_params, - self.event_loop.clone(), + &self.task_locals, ctx, self, ); @@ -139,7 +139,7 @@ impl StreamHandler> for MyWs { execute_ws_function( handler_function, *number_of_params, - self.event_loop.clone(), + &self.task_locals, ctx, self, ); @@ -153,7 +153,7 @@ impl StreamHandler> for MyWs { execute_ws_function( handler_function, *number_of_params, - self.event_loop.clone(), + &self.task_locals, ctx, self, ); @@ -167,14 +167,14 @@ pub async fn start_web_socket( req: HttpRequest, stream: web::Payload, router: HashMap, - event_loop: Arc, + task_locals: Arc, ) -> Result { // execute the async function here ws::start( MyWs { router, - event_loop, + task_locals, id: Uuid::new_v4(), }, &req,