Ejemplo n.º 1
0
async def init_index(context, subscriber):
    try:
        im = get_adapter(context, IIndexManager)
        utility = query_utility(ICatalogUtility)

        if utility is None:
            return
        index_name = await im.get_index_name()
        real_index_name = await im.get_real_index_name()

        conn = utility.get_connection()

        await utility.create_index(real_index_name, im)
        await conn.indices.put_alias(name=index_name, index=real_index_name)
        await conn.indices.close(real_index_name)

        await conn.indices.open(real_index_name)

        await conn.cluster.health(wait_for_status="yellow")
        alsoProvides(context, IIndexActive)

        execute.add_future(
            "cleanup-" + context.uuid,
            _teardown_failed_request_with_index,
            scope="failure",
            args=[im],
        )
    except Exception:
        logger.error("Error creating index for content", exc_info=True)
        raise
Ejemplo n.º 2
0
    def add_future(self, *args, **kwargs):
        '''
        Register a future to be executed after the request has finished.

        :param name: name of future
        :param fut: future to execute after request
        :param scope: group the futures to execute different groupings together
        :param args: arguments to execute future with
        :param kwargs: kwargs to execute future with
        '''
        execute.add_future(*args, **kwargs)
Ejemplo n.º 3
0
 def register(self):
     execute.add_future("indexer", self)
Ejemplo n.º 4
0
async def wait_future(context, request):
    execute.add_future("testing", future_func)