This commit is contained in:
@@ -143,6 +143,16 @@
|
||||
#(element/of-keyword-type? % "LATEX_HEADER")
|
||||
(sp/view :value)])))
|
||||
|
||||
(defn timeout-snippet-promises [snippet-promises fut]
|
||||
;; Time out after eight seconds. With all the LaTeX and IPC, there
|
||||
;; are so many opportunities for things to go wrong </3.
|
||||
(let [fut-res (deref fut (* 10 1000) ::timed-out)]
|
||||
(if (= fut-res ::timed-out)
|
||||
(do (future-cancel fut)
|
||||
(doseq [[_snippet p] snippet-promises]
|
||||
(deliver p ::timed-out)))
|
||||
fut-res)))
|
||||
|
||||
(defn render-tex-snippets
|
||||
"Traverse doc, adorning each LaTeX node with a promise resolving to,
|
||||
optimistically, Hiccup-rendered SVG or MathML code."
|
||||
@@ -156,16 +166,10 @@
|
||||
(let [p (promise)]
|
||||
(swap! snippet-promises #(conj % [(:value node) p]))
|
||||
(assoc node ::rendered p)))))
|
||||
fut (-> #(tex/render-snippets @snippet-promises)
|
||||
sp @snippet-promises
|
||||
fut (-> #(tex/render-snippets sp)
|
||||
bound-fn* future-call)]
|
||||
;; Time out after eight seconds. With all the LaTeX and IPC, there
|
||||
;; are so many opportunities for things to go wrong </3.
|
||||
(let [fut-res (deref fut (* 10 1000) ::timed-out)]
|
||||
(if (= fut-res ::timed-out)
|
||||
(do (future-cancel fut)
|
||||
(doseq [[_snippet p] @snippet-promises]
|
||||
(deliver p ::timed-out)))
|
||||
fut-res))
|
||||
(timeout-snippet-promises sp fut)
|
||||
r))
|
||||
|
||||
(comment
|
||||
|
||||
Reference in New Issue
Block a user