Skip to content

Commit

Permalink
treat SSLEOFError as dropped connection
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Aug 21, 2024
1 parent a1db120 commit cf18d03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Unreleased
quoted string values. :issue:`2907`
- Debugger pin auth is synchronized across threads/processes when tracking
failed entries. :issue:`2916`
- Dev server handles unexpected `SSLEOFError` due to issue in Python < 3.13.
:issue:`2926`


Version 3.0.3
Expand Down
9 changes: 8 additions & 1 deletion src/werkzeug/serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@

try:
import ssl

connection_dropped_errors: tuple[type[Exception], ...] = (
ConnectionError,
socket.timeout,
ssl.SSLEOFError,
)
except ImportError:

class _SslDummy:
Expand All @@ -47,6 +53,7 @@ def __getattr__(self, name: str) -> t.Any:
)

ssl = _SslDummy() # type: ignore
connection_dropped_errors = (ConnectionError, socket.timeout)

_log_add_style = True

Expand Down Expand Up @@ -361,7 +368,7 @@ def execute(app: WSGIApplication) -> None:

try:
execute(self.server.app)
except (ConnectionError, socket.timeout) as e:
except connection_dropped_errors as e:
self.connection_dropped(e, environ)
except Exception as e:
if self.server.passthrough_errors:
Expand Down

0 comments on commit cf18d03

Please sign in to comment.