evaluates expr, returning failexpr if an abort occurs.
Details and Options
- By default, CheckAbort absorbs any user aborts (including calls to Abort) it handles, and does not propagate them further.
- Whether CheckAbort absorbs the aborts it handles can be changed with option PropagateAborts, which takes the following settings:
Automatic propagate aborts other than user-initiated aborts (including calls to Abort) True propagate all aborts False propagate no aborts
- CheckAbort works inside AbortProtect. »
- CheckAbort has attribute HoldAll.
Examplesopen allclose all
This can also be done with MemoryConstrained:
Aborts created by TimeConstrained are by default propagated:
Aborts created by MemoryConstrained are similar:
Properties & Relations (5)
The argument is effectively wrapped in AbortProtect:
If an abort is already active when CheckAbort begins, the first argument will not be evaluated:
CheckAbort can be used to perform cleanup if a computation is interrupted:
$myFlag is set to False even for inputs that produce an abort:
WithCleanup accomplishes this same goal with significantly less code:
Wolfram Research (1991), CheckAbort, Wolfram Language function, https://reference.wolfram.com/language/ref/CheckAbort.html (updated 2022).
Wolfram Language. 1991. "CheckAbort." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/CheckAbort.html.
Wolfram Language. (1991). CheckAbort. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CheckAbort.html