Say I process something with ParallelSubmit:


job = ParallelSubmit[1 + 2]


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:

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

Parallel`Developer`ProcessState[job] (* === Parallel`Developer`queued *)
(* 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[]?

  • 1
    $\begingroup$ 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. $\endgroup$ – Szabolcs Apr 21 '15 at 15:03
  • $\begingroup$ 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. $\endgroup$ – Szabolcs Apr 21 '15 at 15:04
  • $\begingroup$ 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. :) $\endgroup$ – Theo Tiger Apr 22 '15 at 8:51

Your Answer

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

Browse other questions tagged or ask your own question.