wcp-library 1.6.4__py3-none-any.whl → 1.6.5__py3-none-any.whl

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.
wcp_library/__init__.py CHANGED
@@ -42,24 +42,21 @@ def divide_chunks(list_obj: list, size: int) -> Generator:
42
42
 
43
43
 
44
44
  def retry(
45
- exception: Type[Exception],
45
+ exceptions: tuple[Type[Exception]],
46
46
  max_attempts: Optional[int] = MAX_ATTEMPTS,
47
47
  delay: Optional[int] = DELAY,
48
48
  backoff: Optional[int] = BACKOFF,
49
49
  jitter: Optional[int] = JITTER,
50
50
  ) -> Callable:
51
- """Decorator to retry a synchronous function on a specified exception with
52
- exponential backoff and jitter.
53
-
54
- Args:
55
- exception (Type[Exception]): The exception type to catch and retry on.
56
- max_attempts (int): Maximum number of retry attempts.
57
- delay (int): Initial delay between retries (in seconds).
58
- backoff (int): Multiplier to increase delay after each failure.
59
- jitter (int): Maximum number of seconds to add randomly to each delay.
60
-
61
- Returns:
62
- Callable: The decorated function with retry logic.
51
+ """
52
+ Decorator to retry a synchronous function on a specified exception with exponential backoff and jitter.
53
+
54
+ :param exceptions: Tuple of exception types to catch and retry on.
55
+ :param max_attempts: Maximum number of retry attempts.
56
+ :param delay: Initial delay between retries (in seconds).
57
+ :param backoff: Multiplier to increase delay after each failure.
58
+ :param jitter: Maximum number of seconds to add randomly to each delay.
59
+ :return: The decorated function with retry logic.
63
60
  """
64
61
 
65
62
  def decorator(func: Callable) -> Callable:
@@ -70,7 +67,7 @@ def retry(
70
67
  for attempt in range(0, max_attempts):
71
68
  try:
72
69
  return func(*args, **kwargs)
73
- except exception as error:
70
+ except exceptions as error:
74
71
  if attempt == max_attempts:
75
72
  logger.error("Retry failed after %d attempts.", max_attempts)
76
73
  raise
@@ -90,24 +87,21 @@ def retry(
90
87
 
91
88
 
92
89
  def async_retry(
93
- exception: Type[Exception],
90
+ exceptions: tuple[Type[Exception]],
94
91
  max_attempts: Optional[int] = MAX_ATTEMPTS,
95
92
  delay: Optional[int] = DELAY,
96
93
  backoff: Optional[int] = BACKOFF,
97
94
  jitter: Optional[int] = JITTER,
98
95
  ) -> Callable:
99
- """Decorator to retry an async function on a specified exception
100
- with exponential backoff and jitter.
101
-
102
- Args:
103
- exception (Type[Exception]): The exception type to catch and retry on.
104
- max_attempts (int): Maximum number of retry attempts.
105
- delay (int): Initial delay between retries (in seconds).
106
- backoff (int): Multiplier to increase delay after each failure.
107
- jitter (int): Maximum number of seconds to add randomly to each delay.
108
-
109
- Returns:
110
- Callable: The decorated async function with retry logic.
96
+ """
97
+ Decorator to retry an async function on a specified exception with exponential backoff and jitter.
98
+
99
+ :param exceptions: Tuple of exception types to catch and retry on.
100
+ :param max_attempts: Maximum number of retry attempts.
101
+ :param delay: Initial delay between retries (in seconds).
102
+ :param backoff: Multiplier to increase delay after each failure.
103
+ :param jitter: Maximum number of seconds to add randomly to each delay.
104
+ :return: The decorated async function with retry logic.
111
105
  """
112
106
 
113
107
  def decorator(func: Callable) -> Callable:
@@ -118,7 +112,7 @@ def async_retry(
118
112
  for attempt in range(0, max_attempts):
119
113
  try:
120
114
  return await func(*args, **kwargs)
121
- except exception as error:
115
+ except exceptions as error:
122
116
  if attempt == max_attempts:
123
117
  logger.error("Retry failed after %d attempts.", max_attempts)
124
118
  raise
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: wcp-library
3
- Version: 1.6.4
3
+ Version: 1.6.5
4
4
  Summary: Common utilites for internal development at WCP
5
5
  Author: Mitch-Petersen
6
6
  Author-email: mitch.petersen@wcap.ca
@@ -1,4 +1,4 @@
1
- wcp_library/__init__.py,sha256=LYRBTbKUbnqHJooAKL2pzJykJ1wFwZfvqUM4LT0gCFo,4328
1
+ wcp_library/__init__.py,sha256=kfv5jNFXKn_iHjGUOp_UDtqAFiogpVRcn4Tpmkho52o,4242
2
2
  wcp_library/browser_automation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  wcp_library/browser_automation/browser.py,sha256=06xKu_lLifRzfj1TBlpZmKUeBoMqa7ye8kj0Aoy27uI,14551
4
4
  wcp_library/browser_automation/interactions.py,sha256=YTYyII81M9qoVU_iYXoF5vHCc1PSj60hStPU-nT-qyA,28941
@@ -23,6 +23,6 @@ wcp_library/sql/__init__.py,sha256=f0JyVyFyUjueQ1XdVmCgmRjzkFENmFKl3BOzrvv3i1I,2
23
23
  wcp_library/sql/oracle.py,sha256=GpqUn7srm4mGxeJAU06tHaMR37zxASSdMZJ3h8KTC-U,19240
24
24
  wcp_library/sql/postgres.py,sha256=cLOurfmad3WqJcE7FiSxUyzo_0patpfMcTfQAoiteuU,18525
25
25
  wcp_library/time.py,sha256=ktSzhK7SZnGPNXobFexnhFGQAcriLCJQKxnO0fed8fQ,1740
26
- wcp_library-1.6.4.dist-info/METADATA,sha256=AH0_KH7Y4RIA41vVgAtr897soW-s0UmaUYDV_g408mA,1393
27
- wcp_library-1.6.4.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
28
- wcp_library-1.6.4.dist-info/RECORD,,
26
+ wcp_library-1.6.5.dist-info/METADATA,sha256=CzgY0bCG4iFsZJhG4Y6Ff2mIaEgJX8QXmBqFqGtO988,1393
27
+ wcp_library-1.6.5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
28
+ wcp_library-1.6.5.dist-info/RECORD,,