Intercepting signal interruptions in Python while using Gurobi (SIGINT, SIGTERM).

91 views
Skip to first unread message

Enrique Fernández

unread,
Oct 29, 2017, 8:07:25 PM10/29/17
to Gurobi Optimization
Hello,

It seems like Gurobi installs its own signal handlers when Gurobi is being used through Python.

Therefore, when I'm running an optimization setup with Python, and I press control + C, Gurobi terminates the optimization.
However, it also seems like Python terminates if I press control+c multiple times.

I would like to handle interruptions (either control+c or sigkill or others) gracefully in my program, but it seems like installing signal handlers doesn't work. It looks like the reason is that Gurobi is "stealing" those handlers, as my python code for handling signal interruptions is not being called at all after Gurobi starts running.

Is there anyway to overcome this issue?


Thanks!

Daniel Espinoza

unread,
Oct 30, 2017, 7:10:17 AM10/30/17
to Gurobi Optimization
Hi Enrique,

You are right, whenever you call model.computeIIS() or model.optimize() Gurobi will install its own signal handling to ensure graceful termination (handling also temporary memory) and saving of solutions when an interruption is requested by the user.
You can set back your handlers after the call to any of those two functions.

Best,
Daniel

Tobias Achterberg

unread,
Oct 30, 2017, 7:18:49 AM10/30/17
to 'Daniel Espinoza' via Gurobi Optimization, Developers
Daniel is right: we basically remove a user's signal handler. Instead, we should store the
return value of the signal() call (which is the old signal handler) and reinstall this one
in GUROclearsignal().

Any reason for not doing this change? In particular, not doing it for v75?

Tobi
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "Gurobi
> Optimization" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> gurobi+un...@googlegroups.com <mailto:gurobi+un...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages