- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
➜
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
| Author | vstinner |
|---|---|
| Recipients | martin.panter, pitrou, serhiy.storchaka, vstinner |
| Date | 2016-04-12.22:49:07 |
| SpamBayes Score | -1.0 |
| Marked as misclassified | Yes |
| Message-id | <1460501347.41.0.70782898945.issue26741@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
|---|
A subprocess.Popen object contains many resources: pipes, a child process (its pid, and an handle on Windows), etc. IMHO it's not safe to rely on the destructor to release all resources. I would prefer to release resources explicitly. For example, use proc.wait() or "with proc:". Attached patch emits a ResourceWarning in Popen destructor if the status of the child process was not read yet. The patch changes also _execute_child() to set the returncode on error, if the child process raised a Python exception. It avoids to emit a ResourceWarning on this case. The patch fixes also unit tests to release explicitly resources. self.addCleanup(p.stdout.close) is not enough: use "with proc:" instead. TODO: fix also the Windows implementation of _execute_child(). |
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2016-04-12 22:49:07 | vstinner | set | recipients: + vstinner, pitrou, martin.panter, serhiy.storchaka |
| 2016-04-12 22:49:07 | vstinner | set | messageid: <1460501347.41.0.70782898945.issue26741@psf.upfronthosting.co.za> |
| 2016-04-12 22:49:07 | vstinner | link | issue26741 messages |
| 2016-04-12 22:49:07 | vstinner | create |
Powered by Roundup Copyright © 1990-2022, Python Software Foundation
Legal Statements
