Skip to main content

Close Active Sessions

Answered

Comments

5 comments

  • David Torres Sanchez
    Gurobi Staff Gurobi Staff

    Hi Sam,

    This sounds like a WLS license. In that case, your token will be held for a minimum of 5 minutes (this can be changed with a parameter) if the environments and models are disposed of correctly: How do I manage Gurobi environments in gurobipy?

    Cheers, 
    David

    0
  • Sam Mugel

    Thanks David!
    Yes, it is a WLS license :)

    It took me some time to dispose my resources correctly but I think I'm doing it correctly now. Could you share more details about this parameter that you mention so I can manage my token lifetime? I'm sorry I could not find references for this in the docs.

    0
  • David Torres Sanchez
    Gurobi Staff Gurobi Staff

    Hi Sam,

    Cool! The parameter is WLSTokenDuration though this needs to be set at the environment level. 
    Similarly with other connection parameters (e.g. see mip1_remote.py).

    Cheers, 
    David

    1
  • Sam Mugel

    Thank you for your quick response. I followed your instructions but unfortunately, my token management is ignored if the time is set to 1. However, It works for 6 seconds. Is 5 minutes the minimum time that a session can be running? 

    with gp.Env(empty=True) as env:

    env.setParam("WLSTokenDuration", 1)
    env.start()

    with gp.Model(env=env) as gurobi_model:
    # optimize
     
    0
  • David Torres Sanchez
    Gurobi Staff Gurobi Staff

    Good catch. We allow smaller values than 5 (minutes), but these get rounded up to 5. From the same place in the docs

    The WLS server will cap the chosen value automatically to be at least 5 minutes and no more than 60 minutes. This behavior may change in the future as well.

    You can set the parameter like this:

    with gp.Env(params={"WLSTokenDuration": 1}) as env:
        with gp.Model(env=env) as gurobi_model:
    # optimize

    If you want, you can reuse the environment for multiple Gurobi models if that helps.

    Cheers, 
    David

    1

Please sign in to leave a comment.