Search code examples
pythonloggingflaskhandler

'CMRESHandler' object has no attribute '_timer'


When my application starts I am getting the exeption '' CMRESHandler 'object has no attribute' _timer '". The exception occurs when you start the CMRESHandler handler to send the logs to Elasticsearch.

The problem occurs only for local development but when I run the project with Docker the error does not occur.

    handler_es = CMRESHandler(
        hosts=[{"host": KIBANA_SERVER, "port": 443}],
        auth_type=CMRESHandler.AuthType.NO_AUTH,
        use_ssl=True,
        es_index_name="authenticator_server",
        es_additional_fields={"project": "myproject", "environment": ENVIRONMENT},
    )
    handler_es.setFormatter(formatter)
    logger.addHandler(handler_es)

Solution

  • I've had this problem too, I think it's a problem with your hostname.

    Try execute:

    sudo hostname localhost

    And run the project again.