DeviceTestContext might fail to bind to the port
Occasionally , the unit-tests might fail with the following error:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <tango.test_context.DeviceTestContext object at 0x7fbc18962c50>
@retry(connect_timeout, [ConnectionFailed, DevFailed])
def connect(self):
if not self.thread.is_alive():
raise RuntimeError(
> 'The server did not start. Check stdout for more information.')
E RuntimeError: The server did not start. Check stdout for more information.
tango/test_context.py:162: RuntimeError
----------------------------------------------- Captured stdout call ------------------------------------------------
Exiting: Server exited with unforseen exception:
unidentifiable C++ exception
Exited
----------------------------------------------- Captured stderr call ------------------------------------------------
omniORB: Failed to bind to address :: port 55098. Address in use?
omniORB: Error: Unable to create an endpoint of this description: giop:tcp::55098
That's because the random port is selected using:
sock = socket.socket()
sock.bind(('', 0))
port = sock.getsockname()[1]
An alternative would be to run the server without specifying a port (-ORBendPoint giop:tcp::
). But how could we get the affected port once the server is running?