(endpoints)
| 129 | |
| 130 | |
| 131 | def wait_server_ready(endpoints): |
| 132 | assert not isinstance(endpoints, str) |
| 133 | while True: |
| 134 | all_ok = True |
| 135 | not_ready_endpoints = [] |
| 136 | for ep in endpoints: |
| 137 | ip_port = ep.split(":") |
| 138 | with contextlib.closing( |
| 139 | socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
| 140 | ) as sock: |
| 141 | sock.settimeout(2) |
| 142 | result = sock.connect_ex((ip_port[0], int(ip_port[1]))) |
| 143 | if result != 0: |
| 144 | all_ok = False |
| 145 | not_ready_endpoints.append(ep) |
| 146 | if not all_ok: |
| 147 | time.sleep(3) |
| 148 | else: |
| 149 | break |
| 150 | |
| 151 | |
| 152 | def init_communicator( |
no test coverage detected