From 47cf2121f66cead008a6bb7a6b6644f970026cd9 Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Tue, 15 Dec 2015 11:19:58 +0700 Subject: [PATCH] [#141] Housekeeping --- src/taoensso/timbre.cljx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/taoensso/timbre.cljx b/src/taoensso/timbre.cljx index d6527fb..e50bd0a 100644 --- a/src/taoensso/timbre.cljx +++ b/src/taoensso/timbre.cljx @@ -564,19 +564,19 @@ #+clj (def get-hostname (enc/memoize* (enc/ms :mins 1) - (fn [] - ;; Android doesn't like this on the main thread - ;; `future` starts the agent threadpool so we use - ;; java.util.concurrent. - (let [executor (java.util.concurrent.Executors/newSingleThreadExecutor) - f_ (.submit executor - ^java.util.concurrent.Callable - (fn [] - (try (.. java.net.InetAddress getLocalHost getHostName) - (catch java.net.UnknownHostException _ "UnknownHost"))))] - (try - (deref f_ 5000 "UnknownHost") - (finally (.shutdown executor))))))) + (fn [] + ;; Android doesn't like this on the main thread. Would use a `future` but + ;; that starts the Clojure agent threadpool which can slow application + ;; shutdown w/o a `(shutdown-agents)` call + (let [executor (java.util.concurrent.Executors/newSingleThreadExecutor) + f_ (.submit executor ^java.util.concurrent.Callable + (fn [] + (try + (.. java.net.InetAddress getLocalHost getHostName) + (catch java.net.UnknownHostException _ "UnknownHost") + (finally (.shutdown executor)))))] + + (deref f_ 5000 "UnknownHost"))))) (comment (get-hostname))