let with_timeout time ~f = Lwt.catch begin fun () -> Lwt_unix.with_timeout time f end begin function | Lwt_unix.Timeout -> fail (`Timeout time) | e -> fail_sys (`With_timeout time, `Exn e) end