[ python-Bugs-1695948 ] logging.handlers.SocketHandler.makeSocket() blocks app

SourceForge.net noreply at sourceforge.net
Mon Apr 9 18:18:17 CEST 2007


Bugs item #1695948, was opened at 2007-04-07 06:22
Message generated for change (Comment added) made by vsajip
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1695948&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: jtdeng (jtdeng)
Assigned to: Vinay Sajip (vsajip)
Summary: logging.handlers.SocketHandler.makeSocket() blocks app

Initial Comment:
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 




----------------------------------------------------------------------

>Comment By: Vinay Sajip (vsajip)
Date: 2007-04-09 16:18

Message:
Logged In: YES 
user_id=308438
Originator: NO

Change (not exactly as above) checked into SVN trunk. New functionality,
so not backported.

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2007-04-09 05:56

Message:
Logged In: YES 
user_id=33168
Originator: NO

Vinay, could you take a look?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1695948&group_id=5470


More information about the Python-bugs-list mailing list