I've noticed that I can't Throw from within a ParallelDo in the same way that I can from inside Do. For instance, the following will work as anticipated with Do but not with ParallelDo:
Catch[ParallelDo[num=RandomInteger[{1,5}];Print[num];If[num==2,Throw[i]],{i,10}]]
It generates errors of the following form:
Throw::nocatch: Uncaught Throw[7] returned to top level.
ParallelDeveloperQueueRun::hmm: Received unexpected result Hold[Throw[7]] from KernelObject[4,local].
As I read it, the Catch isn't passed to the servant kernels, so when the servant kernels try to Throw, they get confused. Meanwhile, the main kernel just receives a Throw[i] and doesn't know how to evaluate it.
Is there any way to have the servant kernels just serve the results no matter what and have the main kernel check the Catch/Throw?
I could probably emulate this by having the servant kernels running Abort in place of Throw, but this feels more like a hack.
This is not unrelated to the problem discussed here, but I only need to return a specific result (the one that I'd like to trigger Throw) rather than all results calculated so far, and I'm working with ParallelDo instead of Table, which I think means it's safely interruptible anyway (see David's answer to the linked question using Abort).