[Python-Dev] Avoiding file descriptors leakage in subprocess.Popen() (original) (raw)
Mark Seaborn mrs at mythic-beasts.com
Sun Jun 14 17:42:55 CEST 2009
- Previous message: [Python-Dev] Avoiding file descriptors leakage in subprocess.Popen()
- Next message: [Python-Dev] Avoiding file descriptors leakage in subprocess.Popen()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Facundo Batista <facundobatista at gmail.com> wrote:
errpiperead, errpipewrite = os.pipe() try: try: ..... ..... ..... ..... ..... ..... finally: os.close(errpipewrite) ..... ..... ..... finally: os.close(errpiperead)
I just don't like a huge try/finally... but as FDs are just ints, do you think is there a better way to handle it?
I use a convenience function like this, so that GC takes care of the FDs:
def make_pipe(): read_fd, write_fd = os.pipe() return os.fdopen(read_fd, "r"), os.fdopen(write_fd, "w")
Mark
- Previous message: [Python-Dev] Avoiding file descriptors leakage in subprocess.Popen()
- Next message: [Python-Dev] Avoiding file descriptors leakage in subprocess.Popen()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]