(args)
| 231 | |
| 232 | |
| 233 | def start_server(args): |
| 234 | server_process = start_server_background(args) |
| 235 | |
| 236 | attempts = 0 |
| 237 | max_attempts = 600 |
| 238 | if 'GITHUB_ACTIONS' in os.environ: |
| 239 | max_attempts *= 2 |
| 240 | |
| 241 | while not is_server_listening(args.host, args.port): |
| 242 | attempts += 1 |
| 243 | if attempts > max_attempts: |
| 244 | assert False, "server not started" |
| 245 | print(f"bench: waiting for server to start ...") |
| 246 | time.sleep(0.5) |
| 247 | |
| 248 | attempts = 0 |
| 249 | while not is_server_ready(args.host, args.port): |
| 250 | attempts += 1 |
| 251 | if attempts > max_attempts: |
| 252 | assert False, "server not ready" |
| 253 | print(f"bench: waiting for server to be ready ...") |
| 254 | time.sleep(0.5) |
| 255 | |
| 256 | print("bench: server started and ready.") |
| 257 | return server_process |
| 258 | |
| 259 | |
| 260 | def start_server_background(args): |
no test coverage detected