MCPcopy
hub / github.com/pallets/werkzeug / retry_after

Method retry_after

src/werkzeug/sansio/response.py:429–448  ·  view source on GitHub ↗

The Retry-After response-header field can be used with a 503 (Service Unavailable) response to indicate how long the service is expected to be unavailable to the requesting client. Time in seconds until expiration or date. .. versionchanged:: 2.0 The dat

(self)

Source from the content-addressed store, hash-verified

427
428 @property
429 def retry_after(self) -> datetime | None:
430 """The Retry-After response-header field can be used with a
431 503 (Service Unavailable) response to indicate how long the
432 service is expected to be unavailable to the requesting client.
433
434 Time in seconds until expiration or date.
435
436 .. versionchanged:: 2.0
437 The datetime object is timezone-aware.
438 """
439 value = self.headers.get("retry-after")
440 if value is None:
441 return None
442
443 try:
444 seconds = int(value)
445 except ValueError:
446 return parse_date(value)
447
448 return datetime.now(timezone.utc) + timedelta(seconds=seconds)
449
450 @retry_after.setter
451 def retry_after(self, value: datetime | int | str | None) -> None:

Callers

nothing calls this directly

Calls 3

parse_dateFunction · 0.85
http_dateFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected