Skip to content

Commit 5216564

Browse files
committed
Always close stdin
1 parent a773018 commit 5216564

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Lib/http/server.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,11 @@ def finish_request():
12931293
while select.select([self.rfile._sock], [], [], 0)[0]:
12941294
if not self.rfile._sock.recv(1):
12951295
break
1296+
try:
1297+
p.stdin.close()
1298+
except OSError:
1299+
# already closed?
1300+
pass
12961301
if self.command.lower() == "post" and nbytes > 0:
12971302
def _in_task():
12981303
"""Pipe the input into the process stdin"""
@@ -1312,11 +1317,6 @@ def _in_task():
13121317
bytes_left -= len(data)
13131318
p.stdin.write(data)
13141319
finish_request()
1315-
try:
1316-
p.stdin.close()
1317-
except OSError:
1318-
# already closed
1319-
pass
13201320
request_relay_thread = threading.Thread(target=_in_task)
13211321
request_relay_thread.start()
13221322
else:

0 commit comments

Comments
 (0)