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 smtp handler (and test) timeout issue #58522

Closed
bitdancer opened this issue Mar 15, 2012 · 4 comments
Closed

logging smtp handler (and test) timeout issue #58522

bitdancer opened this issue Mar 15, 2012 · 4 comments
Assignees
Labels
easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@bitdancer
Copy link
Member

BPO 14314
Nosy @vsajip, @bitdancer

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 2012-03-23.14:38:31.396>
created_at = <Date 2012-03-15.04:59:35.173>
labels = ['easy', 'type-bug', 'library']
title = 'logging smtp handler (and test) timeout issue'
updated_at = <Date 2012-03-23.14:38:31.395>
user = 'https://github.com/bitdancer'

bugs.python.org fields:

activity = <Date 2012-03-23.14:38:31.395>
actor = 'python-dev'
assignee = 'vinay.sajip'
closed = True
closed_date = <Date 2012-03-23.14:38:31.396>
closer = 'python-dev'
components = ['Library (Lib)']
creation = <Date 2012-03-15.04:59:35.173>
creator = 'r.david.murray'
dependencies = []
files = []
hgrepos = []
issue_num = 14314
keywords = ['easy']
message_count = 4.0
messages = ['155858', '155877', '155878', '156664']
nosy_count = 3.0
nosy_names = ['vinay.sajip', 'r.david.murray', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue14314'
versions = ['Python 2.7', 'Python 3.2', 'Python 3.3']

@bitdancer
Copy link
Member Author

I'm working on a patch that updates smtpd, and when I ran the full test suite I got a hang in test_logging. This means there's a bug in my update, but there is also a bug in the logging test.

But see below for another issue I noticed while investigating this, that is the real focus of this report.

This traceback occurs before the test hang:

test_basic (test.test_logging.SMTPHandlerTest) ... error: uncaptured python exception, closing channel <test.test_logging.TestSMTPChannel connected 127.0.0.1:54226 at 0xb5773884> (<class 'AttributeError'>:TestSMTPChannel inst)
Traceback (most recent call last):
  File "/home/rdmurray/python/p33/Lib/logging/handlers.py", line 935, in emit
    smtp.sendmail(self.fromaddr, self.toaddrs, msg)
  File "/home/rdmurray/python/p33/Lib/smtplib.py", line 741, in sendmail
    self.ehlo_or_helo_if_needed()
  File "/home/rdmurray/python/p33/Lib/smtplib.py", line 550, in ehlo_or_helo_if_needed
    if not (200 <= self.ehlo()[0] <= 299):
  File "/home/rdmurray/python/p33/Lib/smtplib.py", line 417, in ehlo
    (code, msg) = self.getreply()
  File "/home/rdmurray/python/p33/Lib/smtplib.py", line 372, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed
Logged from file , line 0

I think the event.wait() in the test should have a timeout; setting it to, say, 5 lets the tests complete (with a failure) in this situation.

Now the real issue:

Looking at the smtp handler code, I notice that unlike the socket handler it doesn't provide any way to set the timeout. This means it could potentially hang forever trying to log an event, which while not related to the above issue is something that I think should be fixed.

I've marked this as behavior, since the SMTP connection should probably get a reasonable default timeout even in bug fix releases, but in 3.3 you'll probably want to make it settable and perhaps shorten the default relative to what you use for the maint releases.

@bitdancer bitdancer added stdlib Python modules in the Lib dir easy type-bug An unexpected behavior, bug, or error labels Mar 15, 2012
@python-dev
Copy link
Mannequin

python-dev mannequin commented Mar 15, 2012

New changeset 4b3f81720809 by Vinay Sajip in branch 'default':
Fixes bpo-14314: Improved SMTP timeout handling.
http://hg.python.org/cpython/rev/4b3f81720809

@vsajip
Copy link
Member

vsajip commented Mar 15, 2012

I've added changes to the test code and a timeout to SMTPHandler (docs still to be updated), and I'll let it run on the buildbots for a bit before looking at timeouts for 3.2/2.7. Marking as pending to remind me.

@vsajip vsajip self-assigned this Mar 15, 2012
@python-dev
Copy link
Mannequin

python-dev mannequin commented Mar 23, 2012

New changeset 113b8e3cbba4 by Vinay Sajip in branch '2.7':
Closes bpo-14314: backported fix.
http://hg.python.org/cpython/rev/113b8e3cbba4

New changeset 54055646fd1f by Vinay Sajip in branch '3.2':
Closes bpo-14314: backported fix.
http://hg.python.org/cpython/rev/54055646fd1f

@python-dev python-dev mannequin closed this as completed Mar 23, 2012
@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
easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants