The Mathematica manual states
TimeConstrained
takes account only of CPU time spent inside the main Mathematica kernel process; it does not include additional threads or processes.
However, my computation involves a parallel computation. As an example, consider the code
count = 0;
SetSharedVariable[count];
ProgressIndicator[Dynamic[count], {0, 500}]
f = Total[ParallelTable[count++; i^2, {i, 1, 500}]];
TimeConstrained[f, .1, "fail"]
(* 41791750 *)
How can I achieve that "fail" is returned. I can imagine that it could be complicated to compute the total CPU time of all sub-processes, but for my application it would be sufficient to consider the absolute amount of real-time that has passed as AbsoluteTiming[]
does.
Any suggestions?