Black (#948)
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
|
||||
|
||||
from .errors import BulkIndexError, ScanError
|
||||
from .actions import expand_action, streaming_bulk, bulk, parallel_bulk
|
||||
from .actions import scan, reindex
|
||||
from .actions import _chunk_actions, _process_bulk_chunk
|
||||
|
||||
|
||||
|
||||
@@ -347,7 +347,7 @@ def parallel_bulk(
|
||||
class BlockingPool(ThreadPool):
|
||||
def _setup_queues(self):
|
||||
super(BlockingPool, self)._setup_queues()
|
||||
# The queue must be at least the size of the number of threads to
|
||||
# The queue must be at least the size of the number of threads to
|
||||
# prevent hanging when inserting sentinel values during teardown.
|
||||
self._inqueue = Queue(max(queue_size, thread_count))
|
||||
self._quick_put = self._inqueue.put
|
||||
@@ -437,7 +437,7 @@ def scan(
|
||||
scroll_id = resp.get("_scroll_id")
|
||||
|
||||
try:
|
||||
while scroll_id and resp['hits']['hits']:
|
||||
while scroll_id and resp["hits"]["hits"]:
|
||||
for hit in resp["hits"]["hits"]:
|
||||
yield hit
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
from ..exceptions import ElasticsearchException
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import time
|
||||
import os
|
||||
|
||||
try:
|
||||
# python 2.6
|
||||
from unittest2 import TestCase, SkipTest
|
||||
@@ -9,33 +10,37 @@ except ImportError:
|
||||
from elasticsearch import Elasticsearch
|
||||
from elasticsearch.exceptions import ConnectionError
|
||||
|
||||
|
||||
def get_test_client(nowait=False, **kwargs):
|
||||
# construct kwargs from the environment
|
||||
kw = {'timeout': 30}
|
||||
if 'TEST_ES_CONNECTION' in os.environ:
|
||||
kw = {"timeout": 30}
|
||||
if "TEST_ES_CONNECTION" in os.environ:
|
||||
from elasticsearch import connection
|
||||
kw['connection_class'] = getattr(connection, os.environ['TEST_ES_CONNECTION'])
|
||||
|
||||
kw["connection_class"] = getattr(connection, os.environ["TEST_ES_CONNECTION"])
|
||||
|
||||
kw.update(kwargs)
|
||||
client = Elasticsearch([os.environ.get('TEST_ES_SERVER', {})], **kw)
|
||||
client = Elasticsearch([os.environ.get("TEST_ES_SERVER", {})], **kw)
|
||||
|
||||
# wait for yellow status
|
||||
for _ in range(1 if nowait else 100):
|
||||
try:
|
||||
client.cluster.health(wait_for_status='yellow')
|
||||
client.cluster.health(wait_for_status="yellow")
|
||||
return client
|
||||
except ConnectionError:
|
||||
time.sleep(.1)
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
# timeout
|
||||
raise SkipTest("Elasticsearch failed to start.")
|
||||
|
||||
|
||||
def _get_version(version_string):
|
||||
if '.' not in version_string:
|
||||
if "." not in version_string:
|
||||
return ()
|
||||
version = version_string.strip().split('.')
|
||||
version = version_string.strip().split(".")
|
||||
return tuple(int(v) if v.isdigit() else 999 for v in version)
|
||||
|
||||
|
||||
class ElasticsearchTestCase(TestCase):
|
||||
@staticmethod
|
||||
def _get_client():
|
||||
@@ -48,13 +53,12 @@ class ElasticsearchTestCase(TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
super(ElasticsearchTestCase, self).tearDown()
|
||||
self.client.indices.delete(index='*', ignore=404)
|
||||
self.client.indices.delete_template(name='*', ignore=404)
|
||||
self.client.indices.delete(index="*", ignore=404)
|
||||
self.client.indices.delete_template(name="*", ignore=404)
|
||||
|
||||
@property
|
||||
def es_version(self):
|
||||
if not hasattr(self, '_es_version'):
|
||||
version_string = self.client.info()['version']['number']
|
||||
if not hasattr(self, "_es_version"):
|
||||
version_string = self.client.info()["version"]["number"]
|
||||
self._es_version = _get_version(version_string)
|
||||
return self._es_version
|
||||
|
||||
|
||||
Reference in New Issue
Block a user