Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Upgrade to requests 1.0. Fixes #47.

  • Loading branch information...
commit 6db7b19fcfc34c4e06a1fef8bcfce99e1ae93068 1 parent 4d1fc2c
@erikrose erikrose authored
View
2  docs/source/changelog.rst
@@ -5,7 +5,7 @@ v1.0 (unreleased)
----------------
* Correct the ``requests`` requirement to require a version that has everything
- we need.
+ we need. In fact, require requests 1.x, which has a stable API.
* Add ``update()`` method.
* Make ``send_request`` method public so you can use ES APIs we don't yet
explicitly support.
View
11 pyelasticsearch/client.py
@@ -9,6 +9,7 @@
import requests
import simplejson as json # for use_decimal
+from simplejson import JSONDecodeError
from pyelasticsearch.downtime import DowntimePronePool
from pyelasticsearch.exceptions import (Timeout, ConnectionError,
@@ -200,10 +201,7 @@ def join_path(path_components):
(method, url, kwargs.get('data', {})))
try:
- # prefetch=True so the connection can be quickly returned to
- # the pool. This is the default in requests >=0.3.16.
- resp = req_method(
- url, prefetch=True, timeout=self.timeout, **kwargs)
+ resp = req_method(url, timeout=self.timeout, **kwargs)
except (ConnectionError, Timeout):
self.servers.mark_dead(server_url)
self.logger.info('%s marked as dead for %s seconds.',
@@ -233,8 +231,9 @@ def _encode_json(self, body):
def _decode_response(self, response):
"""Return a native-Python representation of a response's JSON blob."""
- json_response = response.json
- if json_response is None:
+ try:
+ json_response = response.json()
+ except JSONDecodeError:
raise InvalidJsonResponseError(response)
return json_response
View
4 setup.py
@@ -45,11 +45,11 @@ def find_version(*file_paths):
'Topic :: Internet :: WWW/HTTP :: Indexing/Search'
],
requires=[ # Needed?
- 'requests(>=0.13.3)',
+ 'requests(>=1.0,<2.0)',
'simplejson(>=2.1.0)'
],
install_requires=[
- 'requests>=0.13.3',
+ 'requests>=1.0,<2.0',
'simplejson>=2.1.0'
],
tests_require=['mock'],
Please sign in to comment.
Something went wrong with that request. Please try again.