File tree 2 files changed +18
-2
lines changed 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 4
4
import subprocess
5
5
6
6
setup (name = "singer-python" ,
7
- version = '3.3.4 ' ,
7
+ version = '3.3.5 ' ,
8
8
description = "Singer.io utility library" ,
9
9
author = "Stitch" ,
10
10
classifiers = ['Programming Language :: Python :: 3 :: Only' ],
Original file line number Diff line number Diff line change @@ -143,6 +143,12 @@ def check_config(config, required_keys):
143
143
144
144
145
145
def backoff (exceptions , giveup ):
146
+ """Decorates a function to retry up to 5 times using an exponential backoff
147
+ function.
148
+
149
+ exceptions is a tuple of exception classes that are retried
150
+ giveup is a function that accepts the exception and returns True to retry
151
+ """
146
152
return backoff_module .on_exception (
147
153
backoff_module .expo ,
148
154
exceptions ,
@@ -152,4 +158,14 @@ def backoff(exceptions, giveup):
152
158
153
159
154
160
def exception_is_4xx (exception ):
155
- return exception .response is not None and 400 <= exception .response .status_code < 500
161
+ """Returns True if exception is in the 4xx range."""
162
+ if not hasattr (exception , "response" ):
163
+ return False
164
+
165
+ return exception .response is None :
166
+ return False
167
+
168
+ if not hasattr (exception .response , "status_code" ):
169
+ return False
170
+
171
+ return 400 <= exception .response .status_code < 500
You can’t perform that action at this time.
0 commit comments