Giter VIP home page Giter VIP logo

Comments (1)

pjournou-ipsl avatar pjournou-ipsl commented on June 22, 2024

Thanks for your message.
Your observation is correct.

If we execute the code linked below, which only creates a logger, we can observe the same kind of result with the following lsof Linux command.
$ lsof | grep "x.log"
python3.9 8613 username 6w REG 253,3 0 1077431087 path_to/x.log
python3.9 8613 8616 username 6w REG 253,3 0 1077431087 path_to/x.log
python3.9 8613 8617 username 6w REG 253,3 0 1077431087 path_to/x.log
python3.9 8613 8621 username 6w REG 253,3 0 1077431087 path_to/x.log
python3.9 8613 8622 username 6w REG 253,3 0 1077431087 path_to/x.log
python3.9 8613 8623 username 6w REG 253,3 0 1077431087 path_to/x.log
python3.9 8613 8624 username 6w REG 253,3 0 1077431087 path_to/x.log
python3.9 8613 8625 username 6w REG 253,3 0 1077431087 path_to/x.log
python3.9 8613 8626 username 6w REG 253,3 0 1077431087 path_to/x.log
python3.9 8613 8627 username 6w REG 253,3 0 1077431087 path_to/x.log
python3.9 8613 8628 username 6w REG 253,3 0 1077431087 path_to/x.log

We can see a parent process (PID=8613) an a set of sub-processes (PID=8616, 8617, 8621, ...).
In fact, it's the logging package implementation that creates these threads.

In the documentation, we can read : "The logging module is intended to be thread-safe without any special work needing to be done by its clients. It achieves this though using threading locks; there is one lock to serialize access to the module’s shared data, and each handler also creates a lock to serialize access to its underlying I/O." (source : https://docs.python.org/3/library/logging.html)

If you execute the lsof command with the file name : lsof /path/to/sdt_3.10a/log/transfer.log, you will see a single line as a response (sub-processes are hidden)

In conclusion, we think that your use case is nominal and could not be really a problem.
However, the way that synda implements the logs at the moment will change. We want to enhance this part as soon as possible.

Patrice

The code used for testing :

import logging

_log_format = "%(asctime)s - [%(levelname)s] - %(name)s - (%(filename)s).%(funcName)s(%(lineno)d) - %(message)s"

def get_file_handler():
file_handler = logging.FileHandler("x.log")
file_handler.setLevel(logging.WARNING)
file_handler.setFormatter(logging.Formatter(_log_format))
return file_handler

def get_logger(name):
logger = logging.getLogger(name)
logger.setLevel(logging.INFO)
logger.addHandler(get_file_handler())
return logger

if name == 'main':
logger = get_logger(name)

from synda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.