diff --git a/src/utils/lwt_utils.ml b/src/utils/lwt_utils.ml index b2fcf5e15..cee2b3f7b 100644 --- a/src/utils/lwt_utils.ml +++ b/src/utils/lwt_utils.ml @@ -111,11 +111,12 @@ let queue () : ('a -> unit) * (unit -> 'a list Lwt.t) = queue, wait (* A worker launcher, takes a cancel callback to call upon *) -let worker name ~run ~cancel = +let worker ?(safe=false) name ~run ~cancel = let stop = LC.create () in let fail e = log_error "%s worker failed with %s" name (Printexc.to_string e) ; - cancel () >>= fun () -> Lwt.fail e + cancel () >>= fun () -> + if safe then Lwt.return_unit else Lwt.fail e in let waiter = LC.wait stop in log_info "%s worker started" name ; diff --git a/src/utils/lwt_utils.mli b/src/utils/lwt_utils.mli index 7f42580b7..b3ddc40fa 100644 --- a/src/utils/lwt_utils.mli +++ b/src/utils/lwt_utils.mli @@ -15,6 +15,7 @@ val canceler : unit -> ((unit -> unit Lwt.t) -> unit) val worker: + ?safe:bool -> string -> run:(unit -> unit Lwt.t) -> cancel:(unit -> unit Lwt.t) ->