Skip to content

Commit

Permalink
Merge pull request #3183 from mrmundt/subprocess-timeout
Browse files Browse the repository at this point in the history
Subprocess Timeout Update
  • Loading branch information
michaelbynum authored Mar 8, 2024
2 parents 00adb80 + 78431b7 commit 0cc323a
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion pyomo/contrib/appsi/solvers/ipopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def __init__(self, only_child_vars=False):
self._primal_sol = ComponentMap()
self._reduced_costs = ComponentMap()
self._last_results_object: Optional[Results] = None
self._version_timeout = 2

def available(self):
if self.config.executable.path() is None:
Expand All @@ -158,7 +159,7 @@ def available(self):
def version(self):
results = subprocess.run(
[str(self.config.executable), '--version'],
timeout=1,
timeout=self._version_timeout,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
Expand Down
6 changes: 3 additions & 3 deletions pyomo/contrib/solver/ipopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________

import logging
import os
import subprocess
import datetime
Expand Down Expand Up @@ -39,8 +40,6 @@
from pyomo.core.base.suffix import Suffix
from pyomo.common.collections import ComponentMap

import logging

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -207,6 +206,7 @@ def __init__(self, **kwds):
self._writer = NLWriter()
self._available_cache = None
self._version_cache = None
self._version_timeout = 2

def available(self, config=None):
if config is None:
Expand All @@ -229,7 +229,7 @@ def version(self, config=None):
else:
results = subprocess.run(
[str(pth), '--version'],
timeout=1,
timeout=self._version_timeout,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
Expand Down
1 change: 1 addition & 0 deletions pyomo/opt/solver/shellcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def __init__(self, **kwargs):
# a solver plugin may not report execution time.
self._last_solve_time = None
self._define_signal_handlers = None
self._version_timeout = 2

if executable is not None:
self.set_executable(name=executable, validate=validate)
Expand Down
2 changes: 1 addition & 1 deletion pyomo/solvers/plugins/solvers/CONOPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _get_version(self):
return _extract_version('')
results = subprocess.run(
[solver_exec],
timeout=1,
timeout=self._version_timeout,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
Expand Down
2 changes: 1 addition & 1 deletion pyomo/solvers/plugins/solvers/CPLEX.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def _get_version(self):
return _extract_version('')
results = subprocess.run(
[solver_exec, '-c', 'quit'],
timeout=1,
timeout=self._version_timeout,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
Expand Down
3 changes: 2 additions & 1 deletion pyomo/solvers/plugins/solvers/GLPK.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from pyomo.common import Executable
from pyomo.common.collections import Bunch
from pyomo.common.errors import ApplicationError
from pyomo.opt import (
SolverFactory,
OptSolver,
Expand Down Expand Up @@ -137,7 +138,7 @@ def _get_version(self, executable=None):
[executable, "--version"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
timeout=1,
timeout=self._version_timeout,
universal_newlines=True,
)
return _extract_version(result.stdout)
Expand Down
2 changes: 1 addition & 1 deletion pyomo/solvers/plugins/solvers/IPOPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _get_version(self):
return _extract_version('')
results = subprocess.run(
[solver_exec, "-v"],
timeout=1,
timeout=self._version_timeout,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
Expand Down
2 changes: 1 addition & 1 deletion pyomo/solvers/plugins/solvers/SCIPAMPL.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def _get_version(self, solver_exec=None):
return _extract_version('')
results = subprocess.run(
[solver_exec, "--version"],
timeout=1,
timeout=self._version_timeout,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
Expand Down

0 comments on commit 0cc323a

Please sign in to comment.