Re: with-timeout... ?

2011-03-10 Thread jweiss
I wrote this macro a little while ago because I need that same construct: https://gist.github.com/701051 On Mar 9, 7:12 am, Sean Allen wrote: > Yesterday I was writing a bit of code that needs to wait for an > external event to happen but if it doesn't happen with X amount of > time, > to timeo

Re: with-timeout... ?

2011-03-10 Thread Jeff Rose
In Overtone we have the same situation, where we return a promise representing a server response and sometimes we want to timeout if the response never arrives. This is what we use: (defn await-promise! ([prom] (await-promise prom REPLY-TIMEOUT)) ([prom timeout] (.get (future @prom) time

Re: with-timeout... ?

2011-03-09 Thread Seth
oooh ... I can definitely find a use for this in my project! Thanks for pointing it out. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - ple

Re: with-timeout... ?

2011-03-09 Thread Stuart Sierra
I've been working in this direction with Cljque, for example http://bit.ly/gCtmAl Cljque is still an experiment and has no stable API or documentation. -Stuart Sierra clojure.com -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group

Re: with-timeout... ?

2011-03-09 Thread Seth
Or you could just modify the source of promise ... i dont know why promises dont support timeouts (defprotocol PWait (wait-for [this timeout units] [this timeout])) ;;copied from clojure source, but adding timeout wait-for (defn promise "Alpha - subject to change. Returns a promise obje

Re: with-timeout... ?

2011-03-09 Thread Alan
See https://github.com/Raynes/clojail It's a sandboxing library for Clojure, which among other things means it needs to try running an operation and give up after N seconds. You can skip the sandboxing part entirely if you want; it exposes a pretty general thunk-timeout function. On Mar 9, 4:43 a

Re: with-timeout... ?

2011-03-09 Thread Sean Allen
On Wed, Mar 9, 2011 at 7:25 AM, Baishampayan Ghose wrote: >> Yesterday I was writing a bit of code that needs to wait for an >> external event to happen but if it doesn't happen with X amount of >> time, >> to timeout with an error. >> >> Is there a library to handle this? I know you can do it wit

Re: with-timeout... ?

2011-03-09 Thread Baishampayan Ghose
> Yesterday I was writing a bit of code that needs to wait for an > external event to happen but if it doesn't happen with X amount of > time, > to timeout with an error. > > Is there a library to handle this? I know you can do it with a future > and if you google the general idea, there are a few