Skip to content

Commit 672bed8

Browse files
committed
Added version check for urllib3
1 parent eb6d926 commit 672bed8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/databricks/sql/auth/retry.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import random
33
import time
44
import typing
5+
from importlib.metadata import version
56
from enum import Enum
67
from typing import List, Optional, Tuple, Union
78

@@ -308,8 +309,11 @@ def get_backoff_time(self) -> float:
308309

309310
current_attempt = self.stop_after_attempts_count - int(self.total or 0)
310311
proposed_backoff = (2**current_attempt) * self.delay_min
311-
if self.backoff_jitter != 0.0:
312-
proposed_backoff += random.random() * self.backoff_jitter
312+
313+
library_version = version("urllib3")
314+
if int(library_version.split(".")[0]) >= 2:
315+
if self.backoff_jitter != 0.0:
316+
proposed_backoff += random.random() * self.backoff_jitter
313317

314318
proposed_backoff = min(proposed_backoff, self.delay_max)
315319
self.check_proposed_wait(proposed_backoff)

0 commit comments

Comments
 (0)