I am automating an Aspen Plus simulation through its ActiveX client. My code looks as follow:
import win32com.client as win32
aspen = win32.Dispatch('Apwn.Document')
# Stuff to initialize, mapping inputs and run simulation
aspen.Save()
aspen.Quit()
del aspen
aspen = None
But the process is not killed, still appears in the task manager window.
I tried tu use EnsureDispatch(), pythoncom.CoInitialize() and to kill it with subprocess module. Nothing works. When I force to kill it through cmd:
taskkill /im AspenPlus.exe /f
I get the following error message:
ERROR: The process "AspenPlus.exe" could not be terminated with PID 1100.
Reason: There is no active instance of the task.
The issue is that I want these automation to solve an optimization problem, which means I have to run the simulation several times in a loop and it will amalgamate these "instanceless" processes. Each one takes 117 MB of memory so it will collapse.
Any solution to really kill the process inside my Python code?
Thanks in avance!