Raised when no workers are available for the requested app. This exception is raised when a request targets an app that has worker limits configured, and no workers with that app are currently available (e.g., all workers for that app crashed and haven't been respawned yet).
| 134 | |
| 135 | |
| 136 | class DirtyNoWorkersAvailableError(DirtyError): |
| 137 | """ |
| 138 | Raised when no workers are available for the requested app. |
| 139 | |
| 140 | This exception is raised when a request targets an app that has |
| 141 | worker limits configured, and no workers with that app are currently |
| 142 | available (e.g., all workers for that app crashed and haven't been |
| 143 | respawned yet). |
| 144 | |
| 145 | Web applications can catch this exception to provide graceful |
| 146 | degradation, such as queuing requests for retry or showing a |
| 147 | maintenance page. |
| 148 | |
| 149 | Example:: |
| 150 | |
| 151 | from gunicorn.dirty import get_dirty_client |
| 152 | from gunicorn.dirty.errors import DirtyNoWorkersAvailableError |
| 153 | |
| 154 | def my_view(request): |
| 155 | client = get_dirty_client() |
| 156 | try: |
| 157 | result = client.execute("myapp.ml:HeavyModel", "predict", data) |
| 158 | except DirtyNoWorkersAvailableError as e: |
| 159 | return {"error": "Service temporarily unavailable", |
| 160 | "app": e.app_path} |
| 161 | """ |
| 162 | |
| 163 | def __init__(self, app_path, message=None): |
| 164 | if message is None: |
| 165 | message = f"No workers available for app: {app_path}" |
| 166 | super().__init__(message, details={"app_path": app_path}) |
| 167 | self.app_path = app_path |
| 168 | |
| 169 | |
| 170 | class DirtyProtocolError(DirtyError): |
no outgoing calls