From f7bf44f64ca3676915fce4387f2dcb5d3e14212e Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Mon, 10 Jan 2022 02:37:25 -0500 Subject: [PATCH] proved we can have multiple threads now Old setup was blocking, must have executed on the same runtime thread Need a way to prevent people from spinning up multiple threads. --- .../src/endpoints_ws/obs_gateway_websocket_handler.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/service/obs_gateway/src/endpoints_ws/obs_gateway_websocket_handler.rs b/crates/service/obs_gateway/src/endpoints_ws/obs_gateway_websocket_handler.rs index f76cf66d35..700eb839d1 100644 --- a/crates/service/obs_gateway/src/endpoints_ws/obs_gateway_websocket_handler.rs +++ b/crates/service/obs_gateway/src/endpoints_ws/obs_gateway_websocket_handler.rs @@ -14,6 +14,7 @@ use crate::endpoints_ws::obs_twitch_thread::ObsTwitchThread; use std::thread::sleep; use std::time::Duration; use actix_rt::Runtime; +use container_common::token::random_crockford_token::random_crockford_token; /// Endpoint pub async fn obs_gateway_websocket_handler( @@ -106,6 +107,7 @@ impl Actor for ObsGatewayWebSocket { info!(">>>>>> obs actor started"); + let token = random_crockford_token(6); info!("before spawn thread"); @@ -113,7 +115,7 @@ impl Actor for ObsGatewayWebSocket { let handle = Handle::current(); //let rt = Runtime::new().unwrap(); - handle.spawn_blocking(|| { + handle.spawn_blocking(move || { //error!("Twitch PubSub Try read next..."); //match client2.try_next().await { // Ok(r) => { @@ -124,7 +126,7 @@ impl Actor for ObsGatewayWebSocket { // } //} loop { - info!("thread loop"); + info!("[{}] thread loop", token); sleep(Duration::from_millis(1000)); } });