Third-party modeling frameworks such as Pyomo and PuLP are common ways of using Gurobi in Python. These frameworks do not expose the underlying Gurobi model or environment objects to the user. As a result, it may not be possible to properly dispose of the Gurobi environment after solving. When using a Gurobi token server, a side effect of this behavior is that tokens are not properly released.
There are two ways to solve this problem:
- Use Gurobi's native Python API instead of a third-party modeling framework. This will give you full access to all of Gurobi's features, including environment/token management. It is also generally more efficient at building models.
- After the optimization completes, delete the main object used by the modeling framework via the del operator. Afterwards, dispose of the default Gurobi environment by calling Gurobi's disposeDefaultEnv() function. This will free the corresponding token.
- How does a client communicate with the token server?
- How do I use Docker with a token server license?