I am running a Nastran simulation through Python.
nastran=subprocess.run([nastrandir,fn,"parallel = 4","old=no",outputarg])
These simulations tend to run for quite some time without feedback, so I am trying to automate reading the output file for relevant data and printing it.
To do that, I need to run some code during the subprocess runtime. However, this does not seem to work. As a simple test I wrote this code beneath the subprocess
command:
while nastran.poll() is None:
print("Still working \r")
time.sleep(delay)
print("Still working. \r")
time.sleep(delay)
print("Still working.. \r")
time.sleep(delay)
print("Still working...\r")
time.sleep(delay)
Unfortunately, the code seems to get stuck at the subprocess
command and waits for it to finish, at which point nastran
becomes a CompletedProcess
class and can no longer be polled, which is the error I receive.
Any idea on how I can get Python to properly poll my Nastran subprocess?