Skip to content

Commit f61e275

Browse files
committed
Disable requests-futures warning messages and don't raise for 302
1 parent 5180963 commit f61e275

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

planet/api/dispatch.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from contextlib import contextmanager
1516
import logging
1617
import os
1718
import re
@@ -150,8 +151,20 @@ def response(self, request):
150151
return Response(request, self)
151152

152153
def _dispatch_async(self, request, callback):
153-
return _do_request(self._asyncpool, request, stream=True,
154-
background_callback=callback)
154+
155+
@contextmanager
156+
def no_futuressession_logging():
157+
logger = logging.getLogger("FuturesSession")
158+
prev_level = logger.getEffectiveLevel()
159+
try:
160+
logger.setLevel(logging.CRITICAL)
161+
yield
162+
finally:
163+
logger.setLevel(prev_level)
164+
165+
with no_futuressession_logging():
166+
return _do_request(self._asyncpool, request, stream=True,
167+
background_callback=callback)
155168

156169
def _dispatch(self, request, callback=None):
157170
return _do_request(self.session, request)

planet/api/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def geometry_from_json(obj):
7171
def check_status(response):
7272
'''check the status of the response and if needed raise an APIException'''
7373
status = response.status_code
74-
if status < 300:
74+
if status < 400:
7575
return
7676
exception = {
7777
400: exceptions.BadQuery,

0 commit comments

Comments
 (0)