[Python] fastapi adding eureka is throwing RuntimeError: Cannot run the event loop while...

Discussão em 'Python' iniciado por Stack, Abril 15, 2025.

  1. Stack

    Stack Membro Participativo

    My project have the following structure:

    [​IMG]

    I want to add eureka to my fastapi applicaction, I´'m trying to do that in the init.py file:

    import py_eureka_client.eureka_client as eureka_client
    from fastapi import FastAPI


    app = FastAPI()

    eureka_client.init(eureka_server="http://eureka-primary:8011/eureka/,http://eureka-secondary:8012/eureka/,http://eureka-tertiary:8013/eureka/",
    app_name="your_app_name",
    instance_port=8000)


    Also I'm using uvicorn to run the app like this:

    uvicorn landus.main:app --reload


    But I get the error:

    RuntimeError: Cannot run the event loop while another loop is running


    I saw a few links like this https://github.com/keijack/python-eureka-client/issues/76 but I don't understand how it works, I only know that fastapi or uvicorn are async application and when I add eureka, that is another async application is where a get this error, but don't know how to make it work

    Continue reading...

Compartilhe esta Página