Perform a request until the server reply
(host, port, path_info='/', timeout=3, retries=30)
| 27 | |
| 28 | |
| 29 | def check_server(host, port, path_info='/', timeout=3, retries=30): |
| 30 | """Perform a request until the server reply""" |
| 31 | if retries < 0: |
| 32 | return 0 |
| 33 | time.sleep(.3) |
| 34 | for i in range(retries): |
| 35 | try: |
| 36 | conn = client.HTTPConnection(host, int(port), timeout=timeout) |
| 37 | conn.request('GET', path_info) |
| 38 | res = conn.getresponse() |
| 39 | return res.status |
| 40 | except (OSError, client.HTTPException): |
| 41 | time.sleep(.3) |
| 42 | return 0 |
| 43 | |
| 44 | |
| 45 | class StopableWSGIServer(TcpWSGIServer): |