hi there
Has anyone got an effective approach to setting a timeout on multiple async calls.
So if I send out 10 calls each with it’s own id and timer. I would handle the callback in a wrapper.
Can I determine WHICH timer blew from the call id or is there a better way?
an example usecase
send 10 requests to a weather service each asking for a realtime data on a different city.
set up a wrapper to handle the returning data stream
if a datastream does not start then retry original a call unless number of retries exceeded for that call.
Palli
January 28, 2023, 3:45pm
2
I’m not sure it’s supported in general, but at least see this thread (with a macro to do it, I didn’t read carefully, may only work in some cases, or info there outdated?):
I have a function that can either execute quickly or take a very long time. I want to kill the function after a certain amount of time so I can fall back on a more reliable method. I should be able to do this using a macro. The problem is I am a bit out of my depth. I took info from here and here and this is what I have so far
macro timeout(time,f)
quote
t = Task($f)
schedule(t)
Timer(x -> (istaskdone(t) || Base.throwto(t,InterruptException())),$time)
t
e…
It seems to be supported in some other languages (so maybe reasonable to think should work in all cases in Julia?):
1 Like
THANK YOU @Palli !!! This was the clincher for me from hhaensel
Really helped. Thanks both
dent