Skip to content
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

Subproc wrapper part2 #762

Merged
merged 3 commits into from
Oct 22, 2019
Merged

Subproc wrapper part2 #762

merged 3 commits into from
Oct 22, 2019

Conversation

nerdvegas
Copy link
Contributor

-added new Popen class (subclassed subprocess.Popen) to allow for use as context in py2/3. This fixes a ResourceWarning in py3.
-removed old open and py23.subprocess_Popen functions
-moved a bunch of subproc/script- related functions to new rez.utils.execution module (want to deprecate rez.util at some point)
-fixed DEV_NULL file object left open in some cases

Closes #761

ajohns added 3 commits October 12, 2019 16:17
…rtly)

-added new Popen wrapper to replace utils.system.popen
-allows for Popen as context, which fixes a ResourceWarning in py3 in test_shells (L138)
-I don't know why this warning doesn't also occur in other Popen calls
-use it wherever wait() is used, avoids ResourceWarning in py3
@JeanChristopheMorinPerso
Copy link
Member

I'm not sure I get the point of subclassing Popen if it's just to not call communicate... The cost of _, _ = p.communicate() is the same as p.wait(), but having this py2/3 wrapper cost (maintenance) more than calling communicate IMO. The current implementation of the __exit__ for py2 also doesn't match 100% what's done in the stdlib in py3.

Note that I'm not against the subclass for the stdin and the text thing (well I find the text thing limit, but I can live with it).

The way I see things, the less py2/3 hacks we have, the better the health of the project will be.

@nerdvegas
Copy link
Contributor Author

nerdvegas commented Oct 15, 2019 via email

@maxnbk
Copy link
Contributor

maxnbk commented Oct 15, 2019

testing on cent with py-2.7, 3.6, 3.7, 3.8 has succeeded for me with no ResourceWarning.

@nerdvegas nerdvegas merged commit c552e91 into master Oct 22, 2019
@bpabel bpabel deleted the subproc-wrapper-part2 branch January 19, 2023 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ResourceWarning with ResolvedContext.execute_shell (py3)
3 participants