-
Notifications
You must be signed in to change notification settings - Fork 13
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
ZMQ freezes on first command after session is created #39
Comments
One additional note: Together with #32 one might get the impression that perhaps any |
Update: I gradually increased the timeout from 100 ms to 500 ms, but still got occasional hangups. My next best guess is this suggestion from a related issue in ZMQ.jl: JuliaInterop/ZMQ.jl#87 (comment) function avoidStartupFreeze(omc:: OMCSession)
status = :started
timeout = 0.1
while status != :received
# send a simple command to OMC
send(omc.socket, "getVersion()")
# use julia task to allow recv to run into a timeout
c = Channel()
@async put!(c, (recv(omc.socket), :received));
@async (sleep(timeout); put!(c, (nothing, :timedout));)
data, status = take!(c)
if status == :timedout
@warn("getVersion() timed out in avoidStartupFreeze")
end
end
end This sends |
Update can be found here: THM-MoTE/ModelicaScriptingTools.jl#9 The solution avoids freezes, but ZMQ crashes with a |
Another update: I have now improved the function function avoidStartupFreeze(omc:: OMCSession)
function reconnect(omc:: OMCSession)
try
send(omc.socket, "quit()")
catch e
end
return OMCSession()
end
status = :started
timeout = 0.1
while status != :received
# send a simple command to OMC
send(omc.socket, "getVersion()")
# use julia task to allow recv to run into a timeout
# idea from https://github.com/JuliaInterop/ZMQ.jl/issues/87#issuecomment-131153884
c = Channel()
@async put!(c, (recv(omc.socket), :received));
@async (sleep(timeout); put!(c, (nothing, :timedout));)
data, status = take!(c)
if status == :timedout
omc = reconnect(omc)
end
end
return omc
end So far this works great, although it is more a workaround rather than a solution. |
@CSchoel thank you for that workaround. I also observed the startup freeze, but additionally have problems when running thousands of simulations in a row - at some point the communication fails. |
@DarkVador42 you're welcome. I am happy that it could be of help to someone else. 😄 Is your error by any chance related to a |
@CSchoel, yes, it also happens regularly when I create the OMCSession. Apart from that it also froze when I had thousands of model calls, where it was trapped inside a "wait" function of ZMQ - I cannot be more specific here, since I was not able to reproduce the error... |
Sometimes (quite rarely), the first call to
sendExpression()
after an OMCSession is created freezes.Stacktrace of InterruptException (after CTRL-C):
setupOMCSession is my own code which contains the following relevant lines with the second line being the one that shows up in the stacktrace:
This happens with the release version 0.1.0 of OMJulia. I believe I have also encountered it with the current version from the master branch in the past, but I cannot confirm that since I have switched back to the official released version some time ago.
I will try to introduce a sleep for 100ms between the creation of the Session and the first
sendExpression()
and report back whether this workaround is successful.The text was updated successfully, but these errors were encountered: