bugdantic 0.4.2__tar.gz → 0.4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bugdantic
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: Bugzilla client based on pydantic
5
5
  Author-email: James Graham <james@hoppipolla.co.uk>
6
6
  License-Expression: MPL-2.0
@@ -2,8 +2,9 @@ import base64
2
2
  import enum
3
3
  import json
4
4
  import logging
5
+ import time
5
6
  from collections.abc import Mapping, MutableMapping, Sequence
6
- from dataclasses import dataclass
7
+ from dataclasses import dataclass, field
7
8
  from datetime import datetime
8
9
  from typing import (
9
10
  Any,
@@ -436,6 +437,7 @@ class BugzillaConfig:
436
437
  allow_writes: bool = False
437
438
  # Number of times to retry a request if there's a 503 error
438
439
  max_retries: int = 1
440
+ retry_status_codes: set[int] = field(default_factory=lambda: {502, 503})
439
441
 
440
442
 
441
443
  BugType = TypeVar("BugType", bound=BaseModel)
@@ -496,18 +498,30 @@ class Bugzilla:
496
498
  path = path.removeprefix("/")
497
499
 
498
500
  url = urljoin(self.config.base_url, f"/rest/{path}")
499
-
501
+ logging.debug("Fetching from bugzilla: %s", url)
500
502
  if self.config.allow_writes or method in {"GET", "OPTIONS", "HEAD"}:
501
503
  retry = 0
502
504
  if self.config.max_retries < 0:
503
505
  raise ValueError("max_retries must be at least 0")
504
506
  response = None
505
507
  while retry <= self.config.max_retries:
508
+ if retry != 0:
509
+ wait_time = 2**retry
510
+ logging.debug(
511
+ "Request failed, retrying %s/%s, sleeping %ss",
512
+ retry,
513
+ self.config.max_retries,
514
+ wait_time,
515
+ )
516
+ time.sleep(wait_time)
506
517
  retry += 1
507
- response = self.client.request(
508
- method, url, params=params, headers=headers, json=json_body
509
- )
510
- if response.status_code != 503:
518
+ try:
519
+ response = self.client.request(
520
+ method, url, params=params, headers=headers, json=json_body
521
+ )
522
+ except httpx.ReadTimeout:
523
+ continue
524
+ if response.status_code not in self.config.retry_status_codes:
511
525
  break
512
526
  assert response is not None
513
527
  try:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bugdantic
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: Bugzilla client based on pydantic
5
5
  Author-email: James Graham <james@hoppipolla.co.uk>
6
6
  License-Expression: MPL-2.0
@@ -5,7 +5,7 @@ authors = [
5
5
  {name = "James Graham", email = "james@hoppipolla.co.uk"}
6
6
  ]
7
7
 
8
- version = "0.4.2"
8
+ version = "0.4.3"
9
9
  requires-python = ">=3.11"
10
10
  license = "MPL-2.0"
11
11
  classifiers = [
File without changes
File without changes
File without changes
File without changes