Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deref with timeout #50

Closed
SevereOverfl0w opened this issue Nov 30, 2021 · 2 comments · Fixed by #51
Closed

deref with timeout #50

SevereOverfl0w opened this issue Nov 30, 2021 · 2 comments · Fixed by #51

Comments

@SevereOverfl0w
Copy link
Contributor

So I can wait for a process to die naturally or destroy it (or (deref process 5000 nil) (bb.process/destroy process)).

Could be implemented using https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/Process.html#waitFor(long,java.util.concurrent.TimeUnit) ?

@borkdude
Copy link
Contributor

@SevereOverfl0w IDeref, the interface that process records implement, does not support the timeout arity.
But I guess we could also implement clojure.lang.IBlockingDeref to support that use case.
Note that you can also grab the process with :proc and call waitFor yourself, although I think it's good to support what you wrote above.

@borkdude
Copy link
Contributor

borkdude commented Dec 1, 2021

$ bb -e '(.waitFor (:proc (babashka.process/process ["clojure" "-M" "-e" "(Thread/sleep 10000)"])) 1000 java.util.concurrent.TimeUnit/MILLISECONDS)'
false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants