Skip to content
Snippets Groups Projects
Unverified Commit d81ba5ea authored by Simon Belak's avatar Simon Belak Committed by GitHub
Browse files

Merge pull request #6526 from metabase/async-test-fix-race-condition

Fix potential race condition where the job gets cleaned up too soon.
parents 9532c572 c270ee9c
No related branches found
No related tags found
No related merge requests found
......@@ -7,11 +7,13 @@
(defn result!
"Blocking version of async/result."
[job-id]
(-> #'async/running-jobs
deref ; var
deref ; atom
(get job-id)
deref) ; future
(when-let [f (-> #'async/running-jobs
deref ; var
deref ; atom
(get job-id))]
(when-not (or (future-cancelled? f)
(future-done? f))
@f))
(async/result (ComputationJob job-id)))
(def ^:dynamic *max-while-runtime*
......@@ -19,7 +21,8 @@
10000000)
(defmacro while-with-timeout
"Like while except it runs a maximum of `*max-while-runtime*` milliseconds."
"Like `clojure.core/while` except it runs a maximum of `*max-while-runtime*`
milliseconds (assuming running time for one iteration is << `*max-while-runtime*`)."
[test & body]
`(let [start# (System/currentTimeMillis)]
(while (and ~test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment