Facundo Batista <facundobati...@gmail.com> wrote:

> errpipe_read, errpipe_write = os.pipe()
> try:
>     try:
>         .....
>         .....
>         .....
>         .....
>         .....
>         .....
>     finally:
>         os.close(errpipe_write)
>     .....
>     .....
>     .....
> finally:
>     os.close(errpipe_read)
> 
> 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
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to