Skip to content

ModelExecutionException: Timeout #460

Closed

Description

@psatke

Description

When i run a simulation model that takes more than 10 s, an exception TimeoutExpired is raised. I guess the initial definition in ModelicaSystem.ModelExecutionCmd.timeout is not updated by simargs={"alarm": 120}. I haven't found a solution to change the value of timeout besides overwriting the init value.

Steps to Reproduce

You can run the example.py file in the zip-archive, which will run a thermal building model created by the TEASER workflow. To run it you will need to install modelica library AixLib. The model should take longer than 10 s to calculate.

Example.zip

Expected Behavior

When i specify a flag like --alarm=120, i expect the timeout value to be raised accordingly.

Screenshots

Image

Version and OS

  • Python Version: 3.12.3
  • OMPython Version: dev 5b05821
  • OpenModelica Version: 1.26.3~1-g7583224
  • OS: Linux Ubuntu 24.04.4 LTS

Additional Context

I also had trouble using the simulate(simargs={"override": {"stopTime": 63072000.0}}) feature. It did not raise an error but it also didn't change the time values in the result file, so it seems to be ignored. I don't know if the issues are related or if i made a mistake, since you've recently been working on the override feature (there is a typo in

mod.simulate(simargs={"noEventEmit": None, "noRestart": None, "override": "override": {"e": 0.3, "g": 10}})
).

Activity

  1. syntron commented on Apr 21, 2026

    @syntron
    Contributor

    OMC and OMPython use different timeouts - one within OMC and the other by Python using subprocess to call OMC

    You should be able to modify the Python timeout as follows (main branch):

        omcs = OMPython.OMCSessionLocal(timeout=120.0)
        mod = OMPython.ModelicaSystemOMC(
            session=omcs,
        )
    

    or using v4.0.1:

        omc = OMPython.OMCProcessLocal(timeout=120.0)
        mod = OMPython.ModelicaSystem(
             omc_process=omc,
        )
    

    Untested - please check and provide feedback!

  2. syntron commented on Apr 21, 2026

    @syntron
    Contributor

    stopTime is tested in test_ModelicaSystem.test_getters() and other unittests

  3. psatke commented on Apr 23, 2026

    @psatke
    Author

    I have tested:

    import OMPython
    from pathlib import Path
    
    directory = Path(__file__).resolve().parent
    print(directory)
    omcs = OMPython.OMCSessionLocal(timeout=300.0)
    om = OMPython.ModelicaSystem(
        work_directory=str(directory / "project_0"),
        command_line_options=["-n=1"],
        session=omcs
    )
    
    om.model(
        model_file=directory / "project_0" / "package.mo",
        model_name="project_0.DESN_59630.DESN_59630"
    )
    sim_options = {"startTime": 0.0, "stopTime": 63072000.0, "stepSize": 3600.0}
    om.setSimulationOptions(**sim_options)
    
    om.simulate(simargs={"noEventEmit": None, "alarm": 120})
    

    but the problem still remains with the same exception (timed out after 10.0 seconds).

  4. syntron commented on Apr 23, 2026

    @syntron
    Contributor

    but the problem still remains with the same exception (timed out after 10.0 seconds).

    Quite right - you found a bug - the timeout value is not propagated down to the point there the model executable is called; I will prepare a bug fix

  5. syntron commented on Apr 23, 2026

    @syntron
    Contributor

    @psatke please test PR #463

  6. psatke commented on Apr 24, 2026

    @psatke
    Author

    Thank you for the fix. Now i can set the timeout with:

        omcs = OMPython.OMCSessionLocal(timeout=120.0)
        mod = OMPython.ModelicaSystemOMC(
            session=omcs,
        )
    

    and the simulation runs successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions