Skip to content

Commit 3c67558

Browse files
committed
WIP Use hardcoded timeout of 1 min (#210)
When processing a Flux workflow the process times out when taking more than one minute.
1 parent a2ba292 commit 3c67558

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

project.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,5 @@
141141
:prep-tasks ["compile" ["release"]]}}
142142

143143
:prep-tasks []
144+
:timeout [300000] ; after 5 minutes cancel the processing of a workflow
144145
:jvm-opts ["-Dclojure.tools.logging.factory=clojure.tools.logging.impl/slf4j-factory"])

src/clj/metafacture_playground/process.clj

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
(log/trace "Content" content)
2121
file-path))))
2222

23-
24-
(defn process [flux data transformation]
23+
(defn process-in-timeout [flux data transformation]
2524
(let [inputfile (content->tempfile-path data ".data")
2625
transformationFile (content->tempfile-path transformation ".fix")
2726
out-path (content->tempfile-path "" ".txt")
@@ -34,3 +33,12 @@
3433
(Flux/main (into-array [(content->tempfile-path flux ".flux")]))
3534
(log/info "Executed flux file with Flux/main. Result in" out-path)
3635
(slurp out-path)))
36+
37+
(defn process
38+
"Runs process with a maximum wait of 1 min. Returns result or ::timeout."
39+
[flux data transformation]
40+
(let [fut (future (process-in-timeout flux data transformation))
41+
result (deref fut 60000 ::timeout)]
42+
(when (= result ::timeout)
43+
(future-cancel fut))
44+
result))

0 commit comments

Comments
 (0)