Skip to content

Commit

Permalink
[#141] Housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaoussanis committed Dec 15, 2015
1 parent c380851 commit f35f21e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/taoensso/timbre.cljx
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit f35f21e

Please sign in to comment.