Metacall Goal, ensuring that its execution is not interrupted and preemptively aborted by a timeout of the timeout/3 or timeout/7 predicate. If a timeout would have occurred during the execution of Goal, it is effectively deferred until Goal completes.
The predicate can be used within a computation which is subject to timeouts, to ensure that subgoals which should be executed as an atomic sequence preserve this atomicity at the cost of delaying the execution of TimeOutGoal.
In all other respects the semantics of call_timeout_safe/1 is the same as call/1.
?- timeout(call_timeout_safe((writeln('Goal started'), sleep(5), writeln('Goal completed'))), 3, writeln('Timeout expired!')). Goal started Goal completed Timeout expired! Yes (0.01s cpu)