Skip to content

Commit 37f14b9

Browse files
ne3x7sjoelund
authored andcommitted
Fix ZMQ deadlock when passing quit() to OMC
This fixes an issue with passing quit() to OMC in subsequent calls of OMCSessionZMQ.
1 parent e4b650b commit 37f14b9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

OMPython/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ def _connect_to_omc(self, timeout):
556556
import zmq
557557
context = zmq.Context.instance()
558558
self._omc = context.socket(zmq.REQ)
559+
self._omc.setsockopt(zmq.LINGER, 0) # Dismisses pending messages if closed
559560
self._omc.connect(self._port)
560561

561562
def execute(self, command):
@@ -575,12 +576,12 @@ def execute(self, command):
575576
def sendExpression(self, command, parsed=True):
576577
if self._omc is not None:
577578
self._omc.send_string(str(command))
578-
result = self._omc.recv_string()
579579
if command == "quit()":
580580
self._omc.close()
581581
self._omc = None
582-
return result
582+
return "Force quit"
583583
else:
584+
result = self._omc.recv_string()
584585
if parsed is True:
585586
answer = OMTypedParser.parseString(result)
586587
return answer

0 commit comments

Comments
 (0)