Python logging from multiple threads

后端 未结 2 1490
天涯浪人
天涯浪人 2021-02-02 09:24

I have a log.py module, that is used in at least two other modules (server.py and device.py).

It has these globals:



        
2条回答
  •  野性不改
    2021-02-02 09:42

    Python logging is thread safe:

    • Is Python's logging module thread safe?

    • http://docs.python.org/2/library/logging.html#thread-safety

    So you have no problem in the Python (library) code.

    The routine that you call from multiple threads (WriteLog) does not write to any shared state. So you have no problem in your code.

    So you are OK.

提交回复
热议问题