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.

classification
Title: logging.handlers.SocketHandler.makeSocket() blocks app
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: jtdeng, nnorwitz, vinay.sajip
Priority: normal Keywords:

Created on 2007-04-07 06:22 by jtdeng, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg31721 - (view) Author: jtdeng (jtdeng) Date: 2007-04-07 06:22
Python Version: 
===============
Any Python Version

OS Platform:
============
Debian Linux 2.6.8-2-386 #1 Tue Aug 16 12:46:35 UTC 2005 i686 GNU/Linux
Windows XP SP2

Problem:
========
Member function makeSocket() of logging.handlers.SocketHandler creates a socket with no default timeout, and this may block the app on Linux.

def makeSocket(self):
    """
    A factory method which allows subclasses to define the precise
    type of socket they want.
    """
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((self.host, self.port))
    return s 


if the log receiver on the destination host is not running, the log sender will block the app on socket.connect(), but on windows, socket.connect() will return immediately. So I propose to provide a default timeout value for makeSocket() like below:

def makeSocket(self, timeout=1):
    """
    A factory method which allows subclasses to define the precise
    type of socket they want.
    """
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.settimeout(timeout)
    s.connect((self.host, self.port))
    return s 


msg31722 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-04-09 05:56
Vinay, could you take a look?
msg31723 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2007-04-09 16:18
Change (not exactly as above) checked into SVN trunk. New functionality, so not backported.
History
Date User Action Args
2022-04-11 14:56:23adminsetgithub: 44813
2007-04-07 06:22:08jtdengcreate