subprocess.communicate() doesn't close pipes on Windows #54972
Copy link
Copy link
Closed
Labels
OS-windowsstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
Description
| BPO | 10763 |
|---|---|
| Nosy | @amauryfa, @pitrou, @vstinner |
| Files |
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 = <Date 2010-12-25.22:43:41.873>
created_at = <Date 2010-12-23.11:59:26.308>
labels = ['library', 'OS-windows']
title = "subprocess.communicate() doesn't close pipes on Windows"
updated_at = <Date 2010-12-25.22:43:41.871>
user = 'https://github.com/vstinner'bugs.python.org fields:
activity = <Date 2010-12-25.22:43:41.871>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2010-12-25.22:43:41.873>
closer = 'vstinner'
components = ['Library (Lib)', 'Windows']
creation = <Date 2010-12-23.11:59:26.308>
creator = 'vstinner'
dependencies = []
files = ['20146']
hgrepos = []
issue_num = 10763
keywords = ['patch']
message_count = 2.0
messages = ['124547', '124649']
nosy_count = 4.0
nosy_names = ['amaury.forgeotdarc', 'pitrou', 'vstinner', 'gps']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue10763'
versions = ['Python 3.2']Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
OS-windowsstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
Activity
vstinner commentedon Dec 23, 2010
If more than one file (stdin, stdout and stderr) are pipes, Popen.communicate() uses threads calling _readerthread() on each pipe. But this method doesn't close the pipes, whereas all other communicate implementations (select, poll and the optimization if there is only one pipe) do close all pipes.
Attached patch fixes this issue.
Thanks Antoine for your nice ResourceWarning patch!
vstinner commentedon Dec 25, 2010
Fixed by r87485 (Python 3.2).
I don't want to fix it in 2.7 or 3.1, because maybe someone relies on this bug and it's a minor bug :-) Reopen the issue if you would like a backport.