@@ -316,7 +316,7 @@ def __init__(self, timeout=10.00,
316316 # start up omc executable, which is waiting for the ZMQ connection
317317 self ._start_omc_process (timeout )
318318 # connect to the running omc instance using ZMQ
319- self ._connect_to_omc (timeout )
319+ self ._omc_port = self . _connect_to_omc (timeout )
320320
321321 self ._re_log_entries = None
322322 self ._re_log_raw = None
@@ -485,24 +485,24 @@ def _get_omhome(self, omhome: str = None):
485485 def _get_omc_path (self ) -> pathlib .Path :
486486 return self ._omhome / "bin" / "omc"
487487
488- def _connect_to_omc (self , timeout ):
489- self . _omc_zeromq_uri = "file:///" + self ._port_file
488+ def _connect_to_omc (self , timeout ) -> str :
489+ omc_zeromq_uri = "file:///" + self ._port_file
490490 # See if the omc server is running
491491 attempts = 0
492- self . _port = None
492+ port = None
493493 while True :
494494 if self ._dockerCid :
495495 try :
496- self . _port = subprocess .check_output (["docker" , "exec" , self ._dockerCid , "cat" , self ._port_file ],
497- stderr = subprocess .DEVNULL ).decode ().strip ()
496+ port = subprocess .check_output (["docker" , "exec" , self ._dockerCid , "cat" , self ._port_file ],
497+ stderr = subprocess .DEVNULL ).decode ().strip ()
498498 break
499499 except subprocess .CalledProcessError :
500500 pass
501501 else :
502502 if os .path .isfile (self ._port_file ):
503503 # Read the port file
504504 with open (self ._port_file , 'r' ) as f_p :
505- self . _port = f_p .readline ()
505+ port = f_p .readline ()
506506 os .remove (self ._port_file )
507507 break
508508
@@ -515,16 +515,18 @@ def _connect_to_omc(self, timeout):
515515 f"Could not open file { self ._port_file } " )
516516 time .sleep (timeout / 80.0 )
517517
518- self . _port = self . _port .replace ("0.0.0.0" , self ._serverIPAddress )
519- logger .info (f"OMC Server is up and running at { self . _omc_zeromq_uri } "
518+ port = port .replace ("0.0.0.0" , self ._serverIPAddress )
519+ logger .info (f"OMC Server is up and running at { omc_zeromq_uri } "
520520 f"pid={ self ._omc_process .pid } cid={ self ._dockerCid } " )
521521
522522 # Create the ZeroMQ socket and connect to OMC server
523523 context = zmq .Context .instance ()
524524 self ._omc = context .socket (zmq .REQ )
525525 self ._omc .setsockopt (zmq .LINGER , 0 ) # Dismisses pending messages if closed
526526 self ._omc .setsockopt (zmq .IMMEDIATE , True ) # Queue messages only to completed connections
527- self ._omc .connect (self ._port )
527+ self ._omc .connect (port )
528+
529+ return port
528530
529531 def execute (self , command ):
530532 warnings .warn ("This function is depreciated and will be removed in future versions; "
0 commit comments