2016-09-08 21:13:10 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Copyright (c) 2014 - 2016. *)
|
|
|
|
(* 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 -> ()
|
2017-02-13 17:05:24 +04:00
|
|
|
(* BEGIN HACK
|
|
|
|
ignore error unhandled by cohttp (until PR129 is merged) *)
|
|
|
|
| Unix.Unix_error(Unix.ECONNRESET, _, _)
|
|
|
|
| Unix.Unix_error(Unix.EPIPE, _, _) -> ()
|
|
|
|
(* END HACK *)
|
2016-12-01 21:27:53 +04:00
|
|
|
| exn ->
|
2017-01-14 16:13:27 +04:00
|
|
|
Format.eprintf
|
|
|
|
"@[Uncaught (asynchronous) exception (%d):@ %a@]"
|
|
|
|
(Unix.getpid ())
|
|
|
|
Error_monad.pp_exn exn ;
|
|
|
|
let backtrace = Printexc.get_backtrace () in
|
|
|
|
if String.length backtrace <> 0 then
|
|
|
|
Format.eprintf "\n%s" backtrace ;
|
|
|
|
Format.eprintf "@." ;
|
2016-12-01 21:27:53 +04:00
|
|
|
Lwt.wakeup exit_wakener 1)
|