Issue2253

classification
Title: Error printed to stderr at exit by _socket module
Type: Severity: normal
Components: Versions: Jython 2.7
Milestone:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: pekka.klarck, zyasoft
Priority: high Keywords:

Created on 2015-01-14.21:02:39 by pekka.klarck, last changed 2015-02-09.23:31:03 by zyasoft.

Files
File name Uploaded Description Edit Remove
logging_socket_noise.py pekka.klarck, 2015-01-14.21:02:38
Messages
msg9396 (view) Author: Pekka Klärck (pekka.klarck) Date: 2015-01-14.21:02:38
To reproduce:
- Import _socket module directly or indirectly
- Register one or more logging handlers
- Remove all registered handlers

As a result you got the following message printed to stderr when the interpreter exits:

    No handlers could be found for logger "_socket"

An easy way to reproduce this is running the attached script. I have tested with official beta 3 and latest beta 4 soft launch version.
msg9399 (view) Author: Pekka Klärck (pekka.klarck) Date: 2015-01-15.14:06:50
See also related #2254.
msg9400 (view) Author: Pekka Klärck (pekka.klarck) Date: 2015-01-15.14:19:32
I looked at `logging` code and found out that we can avoid this warning by setting `log.manager.emittedNoHandlerWarning` to True. This is thus how both this and #2254 could be fixed:

    log = logging.getLogger("_socket")
    log.manager.emittedNoHandlerWarning = True
    log.propagate = False
msg9401 (view) Author: Pekka Klärck (pekka.klarck) Date: 2015-01-15.14:37:44
Another solution to fix this would be always registering a handler to the acquired logger and then setting log level to WARNING. If debug logging is needed, level can be then set to DEBUG. This would probably be cleaner than setting somewhat private `manager.emittedNoHandlerWarning`.
msg9477 (view) Author: Jim Baker (zyasoft) Date: 2015-02-02.22:21:59
Fixed as of https://hg.python.org/jython/rev/e37122c32d8a
History
Date User Action Args
2015-02-09 23:31:03zyasoftsetstatus: pending -> closed
2015-02-02 22:21:59zyasoftsetstatus: open -> pending
messages: + msg9477
2015-02-02 20:33:06zyasoftsetpriority: high
assignee: zyasoft
nosy: + zyasoft
2015-01-15 14:37:44pekka.klarcksetmessages: + msg9401
2015-01-15 14:19:33pekka.klarcksetmessages: + msg9400
2015-01-15 14:06:50pekka.klarcksetmessages: + msg9399
2015-01-14 21:02:39pekka.klarckcreate