Closed ytakashina closed 1 year ago
Thank you for reporting this issue. In the current version we do not define any signal handler to call ampl.close()
when some termination signal is received since this method is called automatically when the object is deleted (which, however, may not always happen depending on the signal received). How are you interrupting the python script?
As a workaround you can define the signal handler yourself as follows:
from amplpy import AMPL
import signal
def signal_handler(signal_, frame):
print("signal received: {0}".format(signal_))
global ampl
ampl.close()
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGHUP, signal_handler)
ampl = AMPL()
ampl.read('gk_f10_n1500_m50.mod')
ampl.option['gurobi_options'] = 'outlev=1'
ampl.option['solver'] = 'gurobi'
ampl.solve()
You may need to use other signals depending on how you are interrupting the script.
When I interrupted my python script which was running
AMPL.solve()
,ampl.exe
andampl_gurobi
(solver) remain running whereas the original python script stopped. I think it's great ifamplpy
automatically kills these processes when interrupted.I am using amplpy==0.6.7 on Windows 10.