-
Notifications
You must be signed in to change notification settings - Fork 61
Fix issue with passing quit() to OMC in subsequent calls of OMCSessionZMQ #61
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, the DS_Store file does not belong here. I am also a little bit unsure if the result should really be the string "Force quit" as it is different in other version of OMPython; I think returning None would be more appropriate (this is what is returned when you "don't" return in Python).
I also can't reproduce crashes, because the ZMQ connection is set to None and subsequent calls to quit() do not perform any action.
Note: Having the call to quit() do something special is a little odd to me anyway. I would have preferred to have:
with OMSessionZMQ() as om:
om.sendExpression(...)
...
Automatically closes the connection
But this is old crap...
If there would be a testcase added for this I would be happy to try to reproduce it.
I cherry-picked and fixed your commit to #67. Perhaps this fix helps with the odd behavior I saw when trying to run OMPython on our Jenkins server. |
Thanks for your response. In order to reproduce the issue, prepare a “model.mo” file with a Class class in it and then run:
The issue I encounter is that |
This seems to work fine on my machine with the old master. But if it is a deadlock scenario it might just be that my machine is too fast or simply not overloaded. I'll try to add this test to the new test suite. |
This might be the case. I run it on a virtual machine with very limited specs. |
The tests are based on OpenModelica#61
OK, I added some tests. They don't deadlock because I have quite many fixes for weird behavior of quitting the OM process, including yours which you say fixed the problem as well. |
Hello! I ran into a strange problem, found its source and propose a quick fix. Would be very proud to contribute.
The problem occurs when executing multiple subsequent calls to create and close
OMCSessionZMQ
, for example subsequently creating and managing instances ofModelicaSystem
in a loop.The issue is that at second (and possibly further) repetitions
sendExpression('quit()')
deadlocks inself._omc.recv_string()
. The reason for that, I believe, is improper impact ofsendExpression('quit()')
on OMC in the first repetition.This is a quick fix to allow for desired functionality. The best way to fix this issue is to replace REP/REQ logic in ZMQ to PUSH/PULL logic, which doesn't require responses.