loguru icon indicating copy to clipboard operation
loguru copied to clipboard

OSError: [Errno 9] Bad file descriptor

Open colinshin opened this issue 4 years ago • 7 comments

Python: 3.8.10 64bit Loguru: 0.5.3 OS: CentOS Linux release 7.9.2009 (Core) Traceback (most recent call last): File "/home/venv/lib/python3.8/site-packages/loguru/_handler.py", line 270, in _queued_writer message = queue.get() File "/usr/local/python3/lib/python3.8/multiprocessing/queues.py", line 356, in get res = self._reader.recv_bytes() File "/usr/local/python3/lib/python3.8/multiprocessing/connection.py", line 216, in recv_bytes buf = self._recv_bytes(maxlength) File "/usr/local/python3/lib/python3.8/multiprocessing/connection.py", line 414, in _recv_bytes buf = self._recv(4) File "/usr/local/python3/lib/python3.8/multiprocessing/connection.py", line 379, in _recv chunk = read(handle, remaining) OSError: [Errno 9] Bad file descriptor --- End of logging error --- --- Logging error in Loguru Handler #1 --- Record was: None

colinshin avatar Sep 23 '21 03:09 colinshin

Hi.

Does this error occur randomly or every time a message is logged?

Delgan avatar Sep 24 '21 15:09 Delgan

@Delgan I have such exception form some point for every logged message until the process killed (due to Bad file descriptor I guess). Attached the exceptions part from my log file loguru exceptions.log

I'm using version 0.5.3 with the following configuration:

from loguru import logger

logger.remove()
logger.add("hub.log",
            colorize=True, 
            format="<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | <level>{level:<8}| {message}</level>", 
            level="DEBUG",
            rotation="50 MB", # Automatically rotate too big file
            enqueue=True) # Process/thread safe logging

Can I protect my app from loguru errors with the API by adding a global exception handler or something similar?

Thanks!

aryeko avatar Nov 07 '21 10:11 aryeko

The version I use is' 0.6.0 '. The following error will be prompted after the deployment of Linux docker. How to solve this problem?

--- Logging error in Loguru Handler #3 ---
Record was: None
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/loguru/_handler.py", line 272, in _queued_writer
    message = queue.get()
  File "/usr/local/lib/python3.9/multiprocessing/queues.py", line 366, in get
    res = self._reader.recv_bytes()
  File "/usr/local/lib/python3.9/multiprocessing/connection.py", line 221, in recv_bytes
    buf = self._recv_bytes(maxlength)
  File "/usr/local/lib/python3.9/multiprocessing/connection.py", line 419, in _recv_bytes
    buf = self._recv(4)
  File "/usr/local/lib/python3.9/multiprocessing/connection.py", line 384, in _recv
    chunk = read(handle, remaining)
OSError: [Errno 9] Bad file descriptor
--- End of logging error ---

xiaohange avatar May 14 '22 07:05 xiaohange

I have the same problem in version "0.7.2"

middlestone avatar Nov 27 '23 05:11 middlestone

@middlestone Can you provide more info please, such as how often it occurs and whether a particular action triggers the error?

A fully reproducible example would be of great help. Right now, I can't say if it's a bug within Loguru or not.

Delgan avatar Feb 17 '24 08:02 Delgan