1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Memory Leak on python logging with FastAPI

Discussão em 'Python' iniciado por Stack, Dezembro 19, 2024.

  1. Stack

    Stack Membro Participativo

    I have write a sample to call logger using python FastAPI, but i found that i got memory leek on the server. Did i need to revise my setting?

    from fastapi import FastAPI, Request
    import logging
    from logging.handlers import TimedRotatingFileHandler

    app = FastAPI()

    logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s [%(levelname)s] %(message)s",
    handlers=[
    TimedRotatingFileHandler(f"/log/debug.log", when='midnight', interval=1, backupCount=7),
    ]
    )

    @app.get(f"/")
    def test():
    for i in range(1000):
    logging.info("HELLO WORLD")

    return "OK"


    [​IMG]

    The API is hosted on a ubuntu docker server, call by locust, total 7280 request was sent to the server. It run on python3.9 and using latest FastAPI[standard]

    Update

    I continue to run the load test. And currently, the memory is increasing.

    [​IMG]

    Continue reading...

Compartilhe esta Página