From e28b277980763b88d2828812bff2c0b9546d3d25 Mon Sep 17 00:00:00 2001 From: iximeow Date: Thu, 29 Dec 2022 09:19:07 +0000 Subject: do not use buggy AsyncWrite impl for file transfer, spawn_blocking a blocking task --- src/lua/mod.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/lua') diff --git a/src/lua/mod.rs b/src/lua/mod.rs index 75b9cec..f186e6b 100644 --- a/src/lua/mod.rs +++ b/src/lua/mod.rs @@ -224,13 +224,15 @@ impl BuildEnv { pub async fn run_build(self, script: &[u8]) -> Result<(), LuaError> { let script = script.to_vec(); - let res: Result<(), LuaError> = std::thread::spawn(move || { - self.lua.context(|lua_ctx| { - lua_ctx.load(&script) - .set_name("goodfile")? - .exec() - }) - }).join().unwrap(); + let res: Result<(), LuaError> = tokio::task::spawn_blocking(|| { + std::thread::spawn(move || { + self.lua.context(|lua_ctx| { + lua_ctx.load(&script) + .set_name("goodfile")? + .exec() + }) + }).join().unwrap() + }).await.unwrap(); eprintln!("lua res: {:?}", res); res } -- cgit v1.1