From b0fef3d5cecfdfb3e3c55beaced78c418a302c71 Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Wed, 6 Nov 2013 15:13:14 +0700 Subject: [PATCH] core: don't run getHostName on the main thread (AdamClements) --- src/taoensso/timbre.clj | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/taoensso/timbre.clj b/src/taoensso/timbre.clj index 76ef569..ff71e61 100644 --- a/src/taoensso/timbre.clj +++ b/src/taoensso/timbre.clj @@ -211,10 +211,15 @@ (comment ((make-timestamp-fn "yyyy-MMM-dd" nil) (Date.))) (def get-hostname - (utils/memoize-ttl - 60000 (fn [] (try (.. java.net.InetAddress getLocalHost getHostName) - (catch java.net.UnknownHostException _ - "UnknownHost"))))) + (utils/memoize-ttl 60000 + (fn [] + (let [p (promise)] + (future ; Android doesn't like this on the main thread + (deliver p + (try (.. java.net.InetAddress getLocalHost getHostName) + (catch java.net.UnknownHostException _ + "UnknownHost")))) + @p)))) (defn- wrap-appender-juxt "Wraps compile-time appender juxt with additional runtime capabilities