Function Repository Resource:

EvaluationObjectState

Source Notebook

Interrogate the status of evaluation objects created with ParallelSubmit without waiting for the evaluations to complete

Contributed by: Jon McLoone

ResourceFunction["EvaluationObjectState"][obj]

returns the current evaluation state of EvaluationObject obj.

ResourceFunction["EvaluationObjectState"][{obj1,obj2,}]

returns the current evaluation state for each of the obji.

Details

Possible evaluation states that can be returned are:
"Queued"the evaluation has not yet started
"Running"the evaluation has started but not completed
"Finished"the result is ready to be read using WaitNext or WaitAll

Examples

Basic Examples (6) 

Submit a collection of parallel computations:

In[1]:=
objs = Table[ParallelSubmit[Pause[10]], 16]
Out[1]=

EvaluationObjectState will start the tasks and return their current states:

In[2]:=
ResourceFunction["EvaluationObjectState"][objs]
Out[2]=

The dynamic display of the objects reflects these values:

In[3]:=
objs
Out[3]=

After some time, you can see that some of the tasks have completed their evaluations:

In[4]:=
ResourceFunction["EvaluationObjectState"][objs]
Out[4]=

Because there are "Finished" tasks, WaitNext will not block:

In[5]:=
WaitNext[objs]
Out[5]=

Eventually, all tasks will show as "Finished". Objects that have been returned by WaitNext or WaitAll will have a status of "Removed":

In[6]:=
ResourceFunction["EvaluationObjectState"][objs]
Out[6]=

Applications (1) 

Create a non-blocking version of WaitNext:

In[7]:=
DontWaitNext[obs_List] := If[MemberQ[ResourceFunction["EvaluationObjectState"][obs], "Finished"], WaitNext[obs], Failure["NoFinishedTasks", <||>]]

Publisher

Jon McLoone

Version History

  • 1.0.0 – 14 March 2022

Related Resources

License Information