Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid startup freezes of OMJulia #9

Open
CSchoel opened this issue Nov 12, 2020 · 4 comments
Open

Avoid startup freezes of OMJulia #9

CSchoel opened this issue Nov 12, 2020 · 4 comments

Comments

@CSchoel
Copy link
Member

CSchoel commented Nov 12, 2020

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.

@CSchoel
Copy link
Member Author

CSchoel commented Nov 13, 2020

The restart solution seems to work. I just got the following warnings:

┌ Warning: Discarding frozen connection to OMC with file descriptor 143 and starting new OMC instance. This may leave the old OMCinstance still running on your machine.
└ @ ModelicaScriptingTools ~/.julia/packages/ModelicaScriptingTools/KpoFH/src/Simulation.jl:298
Closing OMC session
┌ Warning: Closing old OMC instance failed with the following error:
│ ZMQ.StateError("Operation cannot be accomplished in current state")
└ @ ModelicaScriptingTools ~/.julia/packages/ModelicaScriptingTools/KpoFH/src/Simulation.jl:306

But no OMC instance was left open after the simulations finished.

@CSchoel
Copy link
Member Author

CSchoel commented Nov 18, 2020

Second time that i encountered a frozen connection with the new solution, still no dangling OMC instance. This seems to work reliably. 👍

@CSchoel
Copy link
Member Author

CSchoel commented Nov 19, 2020

Another interesting observation: It seems possible that the first warning is shown without the second warning, meaning that it is not unreasonable to hope, that closing the OMC will work smoothly. Also: Third occurrence of warning, still no dangling OMC processes. 🎉

@CSchoel
Copy link
Member Author

CSchoel commented Nov 30, 2020

New case report: Two warnings, one dangling OMC instance. This means that the warning message is also justified.

┌ Warning: Discarding frozen connection to OMC with file descriptor 61 and starting new OMC instance. This may leave the old OMCinstance still running on your machine.
└ @ ModelicaScriptingTools ~/.julia/packages/ModelicaScriptingTools/cGAUx/src/Simulation.jl:298
Closing OMC session
┌ Warning: Closing old OMC instance failed with the following error:
│ ZMQ.StateError("Operation cannot be accomplished in current state")
└ @ ModelicaScriptingTools ~/.julia/packages/ModelicaScriptingTools/cGAUx/src/Simulation.jl:306
┌ Warning: Discarding frozen connection to OMC with file descriptor 72 and starting new OMC instance. This may leave the old OMCinstance still running on your machine.
└ @ ModelicaScriptingTools ~/.julia/packages/ModelicaScriptingTools/cGAUx/src/Simulation.jl:298
Closing OMC session
┌ Warning: Closing old OMC instance failed with the following error:
│ ZMQ.StateError("Operation cannot be accomplished in current state")
└ @ ModelicaScriptingTools ~/.julia/packages/ModelicaScriptingTools/cGAUx/src/Simulation.jl:306
[cslz90@cswork ~]$ ps -aux | grep omc
cslz90      6987  0.0  0.2 1287812 42072 pts/0   Sl+  11:35   0:00 omc --interactive=zmq +z=julia.xyzKRHj35I
cslz90      8727  0.0  0.0   6672  2468 pts/2    S+   11:39   0:00 grep --colour=auto omc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant