メインコンテンツへスキップ

Stopping Gurobipy on exception

回答済み

コメント

3件のコメント

  • Mario Ruthmair
    • Gurobi Staff Gurobi Staff

    Hi Lorenzo,

    You said that you are calling Gurobi in a separate thread. If you have a reference to the model object available in your main thread then you could just call model.terminate() from there leading to a clean termination of the solution process in the other thread. Then you could even access solution information etc.

    Or are you required to handle this via exceptions?

    Best regards,
    Mario

    1
  • Lorenzo Castellino
    • Gurobi-versary
    • First Comment
    • First Question

    Dear Mario,

    Thank you for you reply. Unfortunately I don't have a direct reference to the model: this is why I tried catching the exception "manually" in a callback where I could model.terminate(), having a direct reference to the model there. 

     In our usecase we have a single concurrent user Gurobi license and we use a task queue to be able to schedule more models that will be evaluated one after the other. 

    Rising an exception succesfully aborts queued models and also models that are being built, but as soon as the model start being solved no regular Python exception seems to be handled by the gurobipy library.

     

    0
  • Mario Ruthmair
    • Gurobi Staff Gurobi Staff

    Hi Lorenzo,

    We had a discussion with our developers and the following is the answer my colleague Silke already told your colleague Luca. I just add it here for completeness:

    "The exception is ignored simply because Gurobi does not add any signal handlers for this. We only handle signals like Crtl+C in the command line or the interactive mode, but in situations like yours it is the user's responsibility to install a signal handler. However, using signals is not a recommended way for interprocess communication in general. Instead you could use either shared memory (for threads) or a socket which is written to from the parent and then checked by the child process/thread in the POLLING callback."

    Best regards,
    Mario

    0

サインインしてコメントを残してください。