@@ -13,6 +13,8 @@ use rayon::prelude::*;
1313use std:: collections:: HashMap ;
1414use crate :: terminal:: components:: list:: LOADING_PLACEHOLDER ;
1515
16+ const SLEEP_DURATION : u64 = 100 ;
17+
1618type SystemdUnit = (
1719 String ,
1820 String ,
@@ -239,6 +241,7 @@ impl ServiceRepository for SystemdServiceAdapter {
239241 & ( name, "replace" )
240242 ) ?;
241243 reply. ok_or ( "No reply from StartUnit" ) ?;
244+ thread:: sleep ( Duration :: from_millis ( SLEEP_DURATION ) ) ;
242245 let mut service = self . get_unit ( name) ?;
243246 while service. state ( ) . active ( ) . ends_with ( "ing" ) {
244247 service = self . get_unit ( name) ?;
@@ -255,6 +258,7 @@ impl ServiceRepository for SystemdServiceAdapter {
255258 & ( name. to_string ( ) , "replace" )
256259 ) ?;
257260 reply. ok_or ( "No reply from StopUnit" ) ?;
261+ thread:: sleep ( Duration :: from_millis ( SLEEP_DURATION ) ) ;
258262 let mut service = self . get_unit ( name) ?;
259263 while service. state ( ) . active ( ) . ends_with ( "ing" ) {
260264 service = self . get_unit ( name) ?;
@@ -271,6 +275,7 @@ impl ServiceRepository for SystemdServiceAdapter {
271275 & ( name, "replace" )
272276 ) ?;
273277 reply. ok_or ( "No reply from Start" ) ?;
278+ thread:: sleep ( Duration :: from_millis ( SLEEP_DURATION ) ) ;
274279 let mut service = self . get_unit ( name) ?;
275280 while service. state ( ) . active ( ) . ends_with ( "ing" ) {
276281 service = self . get_unit ( name) ?;
@@ -289,6 +294,7 @@ impl ServiceRepository for SystemdServiceAdapter {
289294 & ( vec ! [ name] , false , false ) ,
290295 ) ?;
291296 reply. ok_or ( "No reply from EnableUnitFiles" ) ?;
297+ thread:: sleep ( Duration :: from_millis ( SLEEP_DURATION ) ) ;
292298 self . get_unit ( name)
293299 }
294300
@@ -301,6 +307,7 @@ impl ServiceRepository for SystemdServiceAdapter {
301307 & ( vec ! [ name] , false ) ,
302308 ) ?;
303309 reply. ok_or ( "No reply from DisableUnitFiles" ) ?;
310+ thread:: sleep ( Duration :: from_millis ( SLEEP_DURATION ) ) ;
304311 self . get_unit ( name)
305312 }
306313
@@ -313,6 +320,7 @@ impl ServiceRepository for SystemdServiceAdapter {
313320 & ( vec ! [ name] , false , true )
314321 ) ?;
315322 reply. ok_or ( "No reply from MaskUnitFiles" ) ?;
323+ thread:: sleep ( Duration :: from_millis ( SLEEP_DURATION ) ) ;
316324 self . get_unit ( name)
317325 }
318326
@@ -325,12 +333,14 @@ impl ServiceRepository for SystemdServiceAdapter {
325333 & ( vec ! [ name] , false )
326334 ) ?;
327335 reply. ok_or ( "No reply from UnmaskUnitFiles" ) ?;
336+ thread:: sleep ( Duration :: from_millis ( SLEEP_DURATION ) ) ;
328337 self . get_unit ( name)
329338 }
330339
331340 fn reload_daemon ( & self ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
332341 let proxy = self . manager_proxy ( ) ?;
333342 proxy. call_with_flags :: < & str , ( ) , ( ) > ( "Reload" , MethodFlags :: AllowInteractiveAuth . into ( ) , & ( ) ) ?;
343+ thread:: sleep ( Duration :: from_millis ( SLEEP_DURATION ) ) ;
334344 Ok ( ( ) )
335345 }
336346
0 commit comments