File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -27,8 +27,18 @@ let should_run () = not !should_exit_
27
27
exception ShouldExit
28
28
29
29
let signal_exit =
30
- let do_lwt = lazy (Lwt. wakeup_later signal_exit_lwt () ) in
31
- (* invariant: should_exit_ = (Lwt.state should_exit_lwt = Lwt.Return) *)
30
+ let do_lwt = lazy (
31
+ (* we can't use Lwt's wakeup_later because it doesn't always "later", it
32
+ soemtimes behaves the same as plain wakeup *)
33
+ Lwt. dont_wait
34
+ (fun () ->
35
+ Lwt. bind
36
+ (Lwt. pause () )
37
+ (fun () -> Lwt. wakeup signal_exit_lwt () ; Lwt. return_unit))
38
+ (fun exc -> log#error " signal exit: error at wakeup: %s" (Printexc. to_string exc))
39
+ )
40
+ in
41
+ (* nearly-invariant: should_exit_ = (Lwt.state should_exit_lwt = Lwt.Return) *)
32
42
fun () -> should_exit_ := true ; Lazy. force do_lwt
33
43
34
44
(* * @raise ShouldExit if [should_exit] condition is set, otherwise do nothing *)
You can’t perform that action at this time.
0 commit comments