Waiting for a job to complete

You can use the Job object's waitForCompletion method to synchronize your script with a job that has been submitted. If you call the waitForCompletion method after you submit a job, the script waits until the analysis is complete before continuing. When the script continues, you should check the status of the job to ensure that the job completed successfully and did not exit. For example, the script described in Reproducing the cantilever beam tutorial uses waitForCompletion to ensure that the analysis job has finished executing successfully before the script opens the resulting output database and displays a contour plot of the results.

In the following example, the script submits myJob1 and waits for it to complete before submitting myJob2.

myJob1 = mdb.Job(name='Job-1')
myJob2 = mdb.Job(name='Job-2')
myJob1.submit()
myJob1.waitForCompletion()
myJob2.submit()
myJob2.waitForCompletion()

If you submit more than one job and then issue a waitForCompletion statement, Abaqus waits until the job associated with the waitForCompletion statement is complete before checking the status of the second job. If the second job has already completed, the waitForCompletion method returns immediately. In the following example the script will not check the status of myJob2 until myJob1 has completed.

myJob1 = mdb.Job(name='Job-1')
myJob2 = mdb.Job(name='Job-2')
myJob1.submit()
myJob2.submit()
myJob1.waitForCompletion()
myJob2.waitForCompletion()