This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author flyte
Recipients flyte
Date 2021-02-10.20:45:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1612989936.74.0.764522656943.issue43196@roundup.psfhosted.org>
In-reply-to
Content
Since https://github.com/python/cpython/commit/b6c1989168efeb8b6320bec958e7e339270ac0ce dictConfig (and presumably fileConfig) has called logging.shutdown() on the existing handlers.

This causes existing SysLogHandlers' sockets to be closed, which then causes a BadFileDescriptor error when you try to use it:

--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.8/logging/handlers.py", line 940, in emit
    self.socket.sendto(msg, self.address)
OSError: [Errno 9] Bad file descriptor
Call stack:
  File "/home/flyte/workspaces/python/test.py", line 18, in <module>
    log.warning("Breaks")

Reproduce the error with the following code:

import logging.config
import socket
from logging.handlers import SysLogHandler

log = logging.getLogger("logtest")
syslog_handler = SysLogHandler(("127.0.0.1", 12345), socktype=socket.SOCK_DGRAM)
log.addHandler(syslog_handler)

log.warning("Works")

logging.config.dictConfig(
    {
        "version": 1,
        "disable_existing_loggers": False,
    }
)

log.warning("Breaks")

This causes issues such as https://github.com/benoitc/gunicorn/issues/2073 where gunicorn sets up a SysLogHandler, then when any app (Django does it by default) calls dictConfig() it closes the socket used by gunicorn's SysLogHandler.

Assuming this also affects Python 3.9 and 3.10, but untested.
History
Date User Action Args
2021-02-10 20:45:36flytesetrecipients: + flyte
2021-02-10 20:45:36flytesetmessageid: <1612989936.74.0.764522656943.issue43196@roundup.psfhosted.org>
2021-02-10 20:45:36flytelinkissue43196 messages
2021-02-10 20:45:36flytecreate