aborts evaluations running in all parallel subkernels.
AbortKernels
aborts evaluations running in all parallel subkernels.
Details
- AbortKernels[] attempts to put subkernels in a state suitable for new evaluations and verifies communications links to them. Any subkernel that does not respond is removed from the list of available subkernels as given by Kernels[].
Examples
open all close allBasic Examples (1)
AbortKernels[]Applications (2)
Scheduled evaluations that are no longer needed can be aborted with AbortKernels:
evs = Composition[ParallelSubmit, FactorInteger] /@ Range[10 ^ 20 + 1, 10 ^ 20 + 4]{res, ev, evs} = WaitNext[evs];resAbortKernels[];Find
such that
is prime, scheduling one search loop for each kernel:
n = 1;primes = {};SetSharedVariable[n, primes];
evs = Table[ParallelSubmit[While[True,
With[{n = n++}, If[PrimeQ[n! + 1], AppendTo[primes, n]]]]], {$KernelCount}];Run them until manually aborted, and clean up by aborting all parallel kernels:
PrintTemporary[Dynamic[{n, primes}]];
CheckAbort[WaitAll[evs], AbortKernels[]];
{n, primes}Properties & Relations (2)
ParallelTry is essentially implemented in terms of WaitNext and AbortKernels:
parallelTry[f_, args_List] := Module[{evs, ev, res = $Failed},
evs = Composition[ParallelSubmit, f] /@ args;
While[res === $Failed && Length[evs] > 0, {res, ev, evs} = WaitNext[evs]];
AbortKernels[];
res
]parallelTry[FactorInteger, Range[10 ^ 20 + 1, 10 ^ 20 + $KernelCount]]If aborting fails, kernels can often be closed and reopened:
Kernels[]CloseKernels[]LaunchKernels[%]See Also
Related Guides
History
Text
Wolfram Research (2008), AbortKernels, Wolfram Language function, https://reference.wolfram.com/language/ref/AbortKernels.html.
CMS
Wolfram Language. 2008. "AbortKernels." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/AbortKernels.html.
APA
Wolfram Language. (2008). AbortKernels. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AbortKernels.html
BibTeX
@misc{reference.wolfram_2026_abortkernels, author="Wolfram Research", title="{AbortKernels}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/AbortKernels.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_abortkernels, organization={Wolfram Research}, title={AbortKernels}, year={2008}, url={https://reference.wolfram.com/language/ref/AbortKernels.html}, note=[Accessed: 13-June-2026]}