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

wsgiref.simple_server.WSGIRequestHandler doesn't log request timeouts #68480

Open
JonathanKamens mannequin opened this issue May 26, 2015 · 1 comment
Open

wsgiref.simple_server.WSGIRequestHandler doesn't log request timeouts #68480

JonathanKamens mannequin opened this issue May 26, 2015 · 1 comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@JonathanKamens
Copy link
Mannequin

JonathanKamens mannequin commented May 26, 2015

BPO 24292
Nosy @pjeby, @berkerpeksag

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 = None
closed_at = None
created_at = <Date 2015-05-26.20:28:40.885>
labels = ['type-bug', 'library']
title = "wsgiref.simple_server.WSGIRequestHandler doesn't log request timeouts"
updated_at = <Date 2015-05-27.00:43:35.226>
user = 'https://bugs.python.org/JonathanKamens'

bugs.python.org fields:

activity = <Date 2015-05-27.00:43:35.226>
actor = 'berker.peksag'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2015-05-26.20:28:40.885>
creator = 'Jonathan Kamens'
dependencies = []
files = []
hgrepos = []
issue_num = 24292
keywords = []
message_count = 1.0
messages = ['244134']
nosy_count = 3.0
nosy_names = ['pje', 'berker.peksag', 'Jonathan Kamens']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue24292'
versions = ['Python 2.7', 'Python 3.4', 'Python 3.5', 'Python 3.6']

@JonathanKamens
Copy link
Mannequin Author

JonathanKamens mannequin commented May 26, 2015

http.BaseHTTPRequestHandler logs request timeouts. In handle_one_request():

    except socket.timeout as e:
        #a read or a write timed out.  Discard this connection
        self.log_error("Request timed out: %r", e)
        self.close_connection = 1
        return

Unfortunately, wsgiref.simple_server.WSGIRequestHandler, which overrides BaseHTTPRequestHandler's handle() method, does _not_ catch and log request timeouts. Fixing this is a simple matter of wrapping the entire body of its handle() function in a try with this except clause:

except socket.timeout as e:
self.log_error("Request timed out: %r", e)
raise

@JonathanKamens JonathanKamens mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels May 26, 2015
@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 type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

0 participants