Răsfoiți Sursa

detach jsonserver task instead of waiting

ghassmo 5 ani în urmă
părinte
comite
14e984d4b9
1 a modificat fișierele cu 4 adăugiri și 6 ștergeri
  1. 4 6
      src/rpc/jsonserver.rs

+ 4 - 6
src/rpc/jsonserver.rs

@@ -69,7 +69,7 @@ pub async fn listen(
         };
         };
 
 
         // Detach the task to let it run in the background.
         // Detach the task to let it run in the background.
-        task.detach();
+        task.await;
     }
     }
 }
 }
 
 
@@ -87,13 +87,10 @@ pub async fn start(
         io,
         io,
     );
     );
 
 
-    let http_task = executor.spawn(http);
 
 
-    *rpc.started.lock().await = true;
-
-    rpc.wait_for_quit().await?;
+    executor.spawn(http).detach();
 
 
-    http_task.cancel().await;
+    *rpc.started.lock().await = true;
 
 
     Ok(())
     Ok(())
 }
 }
@@ -133,6 +130,7 @@ impl RpcInterface {
         let mut res = Response::new(StatusCode::Ok);
         let mut res = Response::new(StatusCode::Ok);
         res.insert_header("Content-Type", "text/plain");
         res.insert_header("Content-Type", "text/plain");
         res.set_body(response);
         res.set_body(response);
+        
         Ok(res)
         Ok(res)
     }
     }