Esempio n. 1
0
    def connect(self, connection_pool=1, bulk_size=10):
        update_connection_pool(connection_pool)

        try:
            self.connection = ES(self.servers, bulk_size=bulk_size)
        except NoServerAvailable:
            self._log.error('Failed to connect to elastic search server')
            return False
        return True
Esempio n. 2
0
import pyes
from flask import request
from wonder.common import timing
from rockpack.mainsite import app


es_url = app.config.get('ELASTICSEARCH_URL')

if es_url:
    try:
        from pyes.connection_http import update_connection_pool
    except ImportError:
        # not available in earlier pyes versions
        pass
    else:
        update_connection_pool(app.config.get('ELASTICSEARCH_CONNECTION_POOL_MAXSIZE', 4))


class FlushTimer(object):

    class UnstartedTimerError(Exception):
        pass

    __shared_state = {}

    def __init__(self):
        self.__dict__ = self.__shared_state
        self.start_time = None
        self.elapsed = 0

    def start(self):