timeout (in seconds)
(timeout=1)
| 87 | |
| 88 | |
| 89 | def ping(timeout=1): |
| 90 | "timeout (in seconds)" |
| 91 | |
| 92 | global webui_opts |
| 93 | |
| 94 | try: |
| 95 | res = webui_get("/internal/ping", timeout=timeout) |
| 96 | |
| 97 | if res.status_code != 200: |
| 98 | raise ConnectTimeout(res.text) |
| 99 | |
| 100 | if webui_opts is None: |
| 101 | try: |
| 102 | res = webui_post("/sdapi/v1/options", json=DEFAULT_WEBUI_OPTIONS) |
| 103 | if res.status_code != 200: |
| 104 | raise Exception(res.text) |
| 105 | except Exception as e: |
| 106 | print(f"Error setting options: {e}") |
| 107 | |
| 108 | try: |
| 109 | res = webui_get("/sdapi/v1/options") |
| 110 | if res.status_code != 200: |
| 111 | raise Exception(res.text) |
| 112 | |
| 113 | webui_opts = res.json() |
| 114 | except Exception as e: |
| 115 | print(f"Error getting options: {e}") |
| 116 | |
| 117 | return True |
| 118 | except (ConnectTimeout, ConnectionError, ReadTimeout) as e: |
| 119 | raise TimeoutError(e) |
| 120 | |
| 121 | |
| 122 | def load_model(context, model_type, **kwargs): |
no test coverage detected