You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I run hundreds of optimizations a day using Pyomo with the HiGHS Appsi interface. Certain optimizations, non-deterministically, cause the thread to freeze without any text output to stdout or stderr.
As far as I could trace, the thread hangs when the HiGHS model (from highspy) executes:
When I set the highs specific option 'log_to_console' to false this behavior no longer happens.
I'm not an expert but I believe that the context threads created by TeeStream and capture_output to handle output streams are causing the problem.
Steps to reproduce the issue
Unfortunately, I don't know exactly how to share my scenario because creating the model is quite complex and the problem occurs non-deterministically. However, I managed to generate a simple script that mimics part of the code implemented within the appsi_highs interface. The behavior observed in the script below is similar to what I observe in the real-life scenario. If 'log_to_console' is set to True, the thread freezes without error messages. Otherwise, it runs without any problems.
This sounds like a bad interaction between the Python GIL and HiGHS, and is almost certainly related to #3031.
TeeStream / capture_output work by spawning threads to monitor / process / route the stream data. Unfortunately, the implementation of highspy.run() never releases the Python GIL, so the stream processing threads never get a chance to run. Evenutally the intermediate stream buffer eventually fills up and blocks a write() in HiGHS, causing deadlock.
@michaelbynum, I think we need to refactor the solver interface / output processing in appsi_highs to not rely on TeeStream in output/log processing. This probably also applies to other direct interfaces as well?
Summary
Hello, I run hundreds of optimizations a day using Pyomo with the HiGHS Appsi interface. Certain optimizations, non-deterministically, cause the thread to freeze without any text output to stdout or stderr.
As far as I could trace, the thread hangs when the HiGHS model (from highspy) executes:
pyomo/pyomo/contrib/appsi/solvers/highs.py
Line 231 in 3b0edaf
When I set the highs specific option 'log_to_console' to false this behavior no longer happens.
I'm not an expert but I believe that the context threads created by TeeStream and capture_output to handle output streams are causing the problem.
Steps to reproduce the issue
Unfortunately, I don't know exactly how to share my scenario because creating the model is quite complex and the problem occurs non-deterministically. However, I managed to generate a simple script that mimics part of the code implemented within the appsi_highs interface. The behavior observed in the script below is similar to what I observe in the real-life scenario. If 'log_to_console' is set to True, the thread freezes without error messages. Otherwise, it runs without any problems.
Information on your system
Pyomo version: 6.7.0
Python version: 3.9.16
Operating system: Win 11 , also debian based container image
How Pyomo was installed (PyPI, conda, source): pip
Solver (if applicable): highspy 1.5.3
The text was updated successfully, but these errors were encountered: