Search code examples
pythonsubprocessos.systemabaqus

Wait of abacus job to complete when launched from python script


I am trying to run an Abaqus script from Python through the command prompt on a Windows 8 machine.

The issue I am having is I cannot get the Python script to wait until the Abaqus job has completed before moving forward.

Below is some code that I have tried, one at a time:

os.popen('abaqus job=plate ask_delete=OFF')
os.system('abaqus job=plate ask_delete=OFF')
os.system('abaqus job=plate ask_delete=OFF')
subprocess.call('abaqus job=plate ask_delete=OFF',shell=True)
subprocess.check_call('abaqus job=plate ask_delete=OFF',shell=True)

I have also tried using the wait command after the subprocess tools like this:

p1 = subprocess.check_call('abaqus job=plate ask_delete=OFF',shell=True)
p1.wait()

But I get the error: AttributeError: 'int' object has no attribute 'wait'.

I do not want to use a time.sleep() as this causes a fair amount of down time in my code. I am using Python 3.5.2 and Anaconda 4.2.0 (64-bit).


Solution

  • You need to include the abaqus keyword "interactive". e.g.

    abaqus myjob=bob1 ask_delete=off interactive

    Otherwise it will run in the background and all output goes to bob1.log Also, there is a builtin python environment with the abaqus installation that can be used to automate running abaqus jobs. There are more options for job control and monitoring if you use this "abaqus" python