2016-09-08 21:13:10 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
2018-02-06 00:17:03 +04:00
|
|
|
(* Copyright (c) 2014 - 2018. *)
|
2016-09-08 21:13:10 +04:00
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
2016-12-01 21:27:53 +04:00
|
|
|
exception Exit
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2016-12-01 21:27:53 +04:00
|
|
|
let termination_thread, exit_wakener = Lwt.wait ()
|
|
|
|
let exit x = Lwt.wakeup exit_wakener x; raise Exit
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2016-12-01 21:27:53 +04:00
|
|
|
let () =
|
|
|
|
Lwt.async_exception_hook :=
|
|
|
|
(function
|
|
|
|
| Exit -> ()
|
2018-06-11 23:05:33 +04:00
|
|
|
| e ->
|
2017-01-14 16:13:27 +04:00
|
|
|
let backtrace = Printexc.get_backtrace () in
|
2018-06-11 23:05:33 +04:00
|
|
|
Base_logging.(fatal_error Tag.DSL.(fun f ->
|
|
|
|
f "@[<v 2>@[Uncaught (asynchronous) exception (%d):@ %a@]%a@]"
|
|
|
|
-% t event "uncaught_async_exception"
|
|
|
|
-% s pid (Unix.getpid ())
|
|
|
|
-% a exn e
|
|
|
|
-% a exn_trace backtrace)) ;
|
2016-12-01 21:27:53 +04:00
|
|
|
Lwt.wakeup exit_wakener 1)
|