Skip to content

Commit 110b4cd

Browse files
authored
Merge pull request #2498 from pallets/socket-warning
handle unclosed socket resource warning
2 parents bebf46d + b484e54 commit 110b4cd

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Unreleased
1919
- ``LocalProxy.__wrapped__`` is always set to the wrapped object when
2020
the proxy is unbound, fixing an issue in doctest that would cause it
2121
to fail. :issue:`2485`
22+
- Address one ``ResourceWarning`` related to the socket used by
23+
``run_simple``. :issue:`2421`
2224

2325

2426
Version 2.2.1

src/werkzeug/serving.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,9 @@ def run_simple(
10611061
if not is_running_from_reloader():
10621062
s = prepare_socket(hostname, port)
10631063
fd = s.fileno()
1064+
# Silence a ResourceWarning about an unclosed socket. This object is no longer
1065+
# used, the server will create another with fromfd.
1066+
s.detach()
10641067
os.environ["WERKZEUG_SERVER_FD"] = str(fd)
10651068
else:
10661069
fd = int(os.environ["WERKZEUG_SERVER_FD"])

0 commit comments

Comments
 (0)