-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Popen lacking context manager support #919
Comments
Also, @giampaolo, FYI, this happens because stdout/err pipes are not closed. This is related behavior which context manager would solve. |
fixes giampaolo#919, connected to giampaolo#919
Definitively a good idea. Thanks for your PR but I preferred to do this: 9386585 |
fixes giampaolo#919, connected to giampaolo#919
fixes giampaolo#919, connected to giampaolo#919
Actually, ctx manager is not expected to be available in 2 since it was only introduced in 3.2 and IMO compliant behavior should be replicated to not create a behavioral inconsistency prior to 3.2. |
I would also not copy the code to ensure that process context manager behaves exactly like it does in a particular version of Python. |
fixes giampaolo#919, connected to giampaolo#919
fixes giampaolo#919, connected to giampaolo#919
It already works like that. If available (>= 3.2) with 9386585 psutil relies on the exiting
I don't see anything wrong with backporting this functionality as psutil.Popen represents a wrapper on top of subprocess.Popen. |
I'm not arguing it's "wrong" per se, but it's one thing to fix an improper behavior in an existing method, but it's quite another to introduce an API change to the versions where it's not expected in compliant interpreter. A hypothetical code (however awkward and brittle) may rely on checking whether |
This may not be expected or improper for IMO it is just more practical if the interface tries to expose the same things on all python versions as this is a principle which is already applied to all other psutil APIs. The fact that To quote the Python Zen I would argue this is a case where practicality beats purity. I don't expect anybody using |
@giampaolo, ok, I give up, thanks for the fix. 😄 |
Per Python Docs Popen can be used as a context manager.
psutil Popen doesn't replicate this behavior:
The text was updated successfully, but these errors were encountered: