Close Active Sessions
AnsweredHello,
I am using Gurobi with gurobipy. I wanted to ask if there is a way of closing an open session right after my jobs finish.
My observations indicate that once a job starts, gurobi creates a session, a running container and a 5 min token. The three components are disposed after 5 minutes even if my job takes only 1 second to compute.
Also, the dashboard shows the session open for at least 10 minutes, although after that I can see in the table that it only lasted 5 minutes. I am wondering if this could be a bug of some sort.
Thanks in advance for your time
-
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,
David0 -
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 -
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,
David1 -
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:
# optimize0 -
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:
# optimizeIf you want, you can reuse the environment for multiple Gurobi models if that helps.
Cheers,
David1
Please sign in to leave a comment.
Comments
5 comments