Skip to content

Avoid startup freezes of OMJulia #9

@CSchoel

Description

@CSchoel

Sometimes, OMJulia freezes when the first command is sent to the OMC, indefinitely waiting for an answer.

My current solution for this was to attempt to implement a timeout for ZMQ.recv, however this currently yields the following error:

┌ Warning: getVersion() timed out in avoidStartupFreeze
└ @ ModelicaScriptingTools ~/.julia/packages/ModelicaScriptingTools/w5Lny/src/Simulation.jl:309
ERROR: LoadError: ZMQ.StateError("Operation cannot be accomplished in current state")
Stacktrace:
 [1] _send(::ZMQ.Socket, ::Base.RefValue{ZMQ._Message}, ::Bool) at /home/cslz90/.julia/packages/ZMQ/R3wSD/src/comm.jl:14
 [2] send(::ZMQ.Socket, ::String; more::Bool) at /home/cslz90/.julia/packages/ZMQ/R3wSD/src/comm.jl:45
 [3] send at /home/cslz90/.julia/packages/ZMQ/R3wSD/src/comm.jl:43 [inlined]
 [4] avoidStartupFreeze(::OMJulia.OMCSession) at /home/cslz90/.julia/packages/ModelicaScriptingTools/w5Lny/src/Simulation.jl:301
 [5] setupOMCSession(::String, ::String; quiet::Bool, checkunits::Bool) at /home/cslz90/.julia/packages/ModelicaScriptingTools/w5Lny/src/Simulation.jl:339
 [6] withOMC(::var"#53#54", ::String, ::String; quiet::Bool, checkunits::Bool) at /home/cslz90/.julia/packages/ModelicaScriptingTools/w5Lny/src/Simulation.jl:423
 [7] withOMC(::Function, ::String, ::String) at /home/cslz90/.julia/packages/ModelicaScriptingTools/w5Lny/src/Simulation.jl:423
 [8] top-level scope at /home/cslz90/Documents/Promotion/code/2019-schoelzel-inada/scripts/unittests.jl:14
in expression starting at /home/cslz90/Documents/Promotion/code/2019-schoelzel-inada/scripts/unittests.jl:14

I guess when ZMQ freezes during revc, it cannot change its state variables, which lead to a subsequent send operation triggering this StateError. A solution might be to simply restart the whole connection when this occurs.

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