# ParallelSubmit and WaitNext: check if a job is done before calling WaitNext

Say I process something with ParallelSubmit:

LaunchKernels[]

job = ParallelSubmit[1 + 2]

ParallelDeveloperQueueRun[]


Then, I will use WaitNext[{job}] later to retrieve the result of this job, but: I do not want to call the function WaitNext, which blocks the main kernel, before I know that there is at least one finished job.

Unfortunately, these things will not work:

ParallelDeveloperDoneQ[job] (* === False *)
(* will not evaluate to True before the job is done AND retrieved by WaitNext[] *)

ParallelDeveloperProcessState[job] (* === ParallelDeveloperqueued *)
(* same here, will not change to unqueued before the job is done AND retrieved by WaitNext[] *)


Is there any way to find out if a job has finished before calling WaitNext[]?

• I think you need to use QueueRun[] before DoneQ will know that the job has finished. The first time you evaluate QueueRun[], the job will be submitted, but at this point it is not done yet. Of course just a fraction of a second later is finishes running on the subkernel. But the main kernel (where you use DoneQ) does not know this until we trigger a communication with another QueueRun[]. Now DoneQ[job] is True. Try submitting many jobs and looking at their status as they're displayed in blue, green, grey in the notebook. The status changes only on QueueRun[] calls. – Szabolcs Apr 21 '15 at 15:03
• I'm not going to post an answer because this is all just guesses from some experimentation, usage message of QueueRun this doc topic: ParallelTools/tutorial/ConcurrencyManagingParallelProcesses. – Szabolcs Apr 21 '15 at 15:04
• Ha, excellent, it works! Indeed QueueRun[] does not only submit the job, it also receives the result, as stated in the documentation you mentioned. Thank you, looks like an exact answer to me. :) – Theo Tiger Apr 22 '15 at 8:51