Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging.handlers.SocketHandler.makeSocket() blocks app #44813

Closed
jtdeng mannequin opened this issue Apr 7, 2007 · 3 comments
Closed

logging.handlers.SocketHandler.makeSocket() blocks app #44813

jtdeng mannequin opened this issue Apr 7, 2007 · 3 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@jtdeng
Copy link
Mannequin

jtdeng mannequin commented Apr 7, 2007

BPO 1695948
Nosy @vsajip

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/vsajip'
closed_at = <Date 2007-04-09.16:18:17.000>
created_at = <Date 2007-04-07.06:22:08.000>
labels = ['library']
title = 'logging.handlers.SocketHandler.makeSocket() blocks app'
updated_at = <Date 2007-04-09.16:18:17.000>
user = 'https://bugs.python.org/jtdeng'

bugs.python.org fields:

activity = <Date 2007-04-09.16:18:17.000>
actor = 'vinay.sajip'
assignee = 'vinay.sajip'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2007-04-07.06:22:08.000>
creator = 'jtdeng'
dependencies = []
files = []
hgrepos = []
issue_num = 1695948
keywords = []
message_count = 3.0
messages = ['31721', '31722', '31723']
nosy_count = 3.0
nosy_names = ['nnorwitz', 'vinay.sajip', 'jtdeng']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1695948'
versions = ['Python 2.5']

@jtdeng
Copy link
Mannequin Author

jtdeng mannequin commented Apr 7, 2007

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

@jtdeng jtdeng mannequin closed this as completed Apr 7, 2007
@jtdeng jtdeng mannequin assigned vsajip Apr 7, 2007
@jtdeng jtdeng mannequin added the stdlib Python modules in the Lib dir label Apr 7, 2007
@nnorwitz
Copy link
Mannequin

nnorwitz mannequin commented Apr 9, 2007

Vinay, could you take a look?

@vsajip
Copy link
Member

vsajip commented Apr 9, 2007

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

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

1 participant