Timeout

Can anyone help me create a block similar to this?
[scratchblocks]// if time is under 1 seconds and the variable is fetched, report the variable
// otherwise, throw an error "Timeout reached"
get(variable)but timeout after(1)seconds::reporter grey
[/scratchblocks]
If that block already exists somewhere, I wouldn't mind a link that reports to the project.

Can you have one script that says to get the variable, and another script that says wait 1 sec, stop other scripts in sprite, throw error? I guess there should be a sprite that has only those two scripts.

Here's how I would do it. The value input is an any (unevaluated) input.

and here's some tests to make sure it actually works


The reason I wanted to use STOP when the time runs out is that maybe the process that's supposed to report the value is costly, either for the user or for some server that's figuring it out. In a perfect world you'd be able to get a handle on a particular process and use it as input to STOP.

I actually also thought of that, but didn't say anything about it. I wish it were possible to stop continuations, like just sticking the continuation inside the stop block, and maybe the running script will stop. Then again, I don't really know how continuations work so...

Yeah, exactly.

Wasn’t “first class processes” an item on WTSD?

Yeah, but we sort of have that; THIS SCRIPT and THIS CALLER include the relevant environments. (Those names aren't perfect, for that reason, but Jens and I spent a couple of days trying to invent perfect names and failing.)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.