Following up Squish advise:
In the wait_for_port.py, you are using socket.create_connection() where the timeout is set to 1.
Could you increase the timeout here and also put a check before to make sure that port is not in the use anymore, before proceeding to launch the AUT.