Skip to content

Commit

Permalink
Use lwt_ppx instead of Lwt.finally
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterDA authored and kit-ty-kate committed Jan 10, 2022
1 parent 77efe90 commit 07ffea9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 4 additions & 3 deletions lib/oca_lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ let mkdir_p dir =

let rec rm_rf dirname =
let%lwt dir = Lwt_unix.opendir (Fpath.to_string dirname) in
Lwt.finalize begin fun () ->
begin
let rec rm_files () =
match%lwt Lwt_unix.readdir dir with
| "." | ".." -> rm_files ()
Expand All @@ -149,10 +149,11 @@ let rec rm_rf dirname =
rm_files ()
in
try%lwt rm_files () with End_of_file -> Lwt.return_unit
end begin fun () ->
end
[%lwt.finally
let%lwt () = Lwt_unix.closedir dir in
Lwt_unix.rmdir (Fpath.to_string dirname)
end
]

type timer = float ref

Expand Down
6 changes: 1 addition & 5 deletions server/backend/check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ let ocluster_build ~cap ~conf ~base_obuilder ~stdout ~stderr c =

let exec_out ~fexec ~fout =
let stdin, stdout = Lwt_io.pipe () in
let proc =
Lwt.finalize
(fun () -> fexec ~stdout)
(fun () -> Lwt_io.close stdout)
in
let proc = (fexec ~stdout) [%lwt.finally Lwt_io.close stdout] in
let%lwt res = fout ~stdin in
let%lwt () = Lwt_io.close stdin in
let%lwt r = proc in
Expand Down

0 comments on commit 07ffea9

Please sign in to comment.