When I run the below ParallelTry command, it just sits on it and says its being evaluated, but I cant abort it, it doesn't return what I am expecting, and I have to quit the kernel to stop the evaluation. Heres the MWE of my code:

kernels = ParallelTable[$KernelID -> i, {i, $KernelCount}];
CurrentStep = ConstantArray[0, $KernelCount];
SetSharedVariable[kernels, CurrentStep];
PrintTemporary@Dynamic[CurrentStep // Column];
(*Run the parallelized search routine*)
ParallelizedResult = 
  (CurrentStep[[$KernelID /. kernels]] = 
     "Kernel " <> ToString[$KernelID] <> " executing chunk " <> 
    #) &,
        {{1, 1000}, {1001, 2000}, {2001, 3000}, {3001, 4000}, {4001, 
    5000}, {5001, 6000}, {6001, 7000}}]

I would expect this to briefly say (for example)

Kernel 6 executing chunk {1, 1000}
Kernel 5 executing chunk {1001, 2000}
Kernel 4 executing chunk {2001, 3000}
Kernel 3 executing chunk {3001, 4000}
Kernel 2 executing chunk {4001, 5000}
Kernel 1 executing chunk {5001, 6000}

followed by {1, 1000} replacing the above print. It should complete the evaluation in only a split second. However, it just hangs on the first temporary print statement and doesn't allow me to abort the evaluation. I've narrowed it down to the


step. Removing this fixes it, but I don't know why this section is causing the unexpected behavior.

This code has worked before so I don't know why upgrading to 12.1 broke it. Could it be a bug in 12.1? Any help is appreciated!


It appears that this code hangs when the number of slave kernels is less than 7 and executes as expected when the number is 7 or more (see comments). Possible 12.1 bug?

  • $\begingroup$ Very strange. When I set LaunchKernels by hand to the maximal number of kernels: LaunchKernels[8] in my case, I get a result rather fast. But when I use LaunchKernels[$ProcessorCount] I get our problem ($ProcessorCount is 4) $\endgroup$ Mar 12, 2021 at 19:34
  • $\begingroup$ @Daniel Huber does the same problem occur when you use LaunchKernels[4]? $\endgroup$ Mar 13, 2021 at 6:21
  • $\begingroup$ Yes, with LaunchKernels[4] it does occur. $\endgroup$ Mar 13, 2021 at 8:23
  • $\begingroup$ Yes, that is strange. I've noticed that if I launch 7 or more slave kernels, then the code behaves as expected. But if I launch 6 or less ($ProcessorCount = 6 for me), then it hangs. $\endgroup$
    – shanedrum
    Mar 13, 2021 at 9:45


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy