Python Forum

Full Version: should i use os.poll() for 2 reads?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i can't remember how long ago i asked this, but i don't think i got an answer and that may be because i asked in a poor way. i want to read from 2 (or more) pipes from one or more child processes. it could be from 2 separate processes. it could be from 1 process to which there are 2 pipes open, such as the other process' stdout and stderr. but the process i would be coding won't know which pipe will have data ready for reading. i could try to do this like i would do it in that infamous one letter named language. but i am hoping Python offers something better. if it does, i just haven't figured out where it is, yet. i'm still frequently led to the os module for systems stuff, but not all syscalls are accessed there. and for most of the things i am doing this is probably the wrong place to look, even if a solution is there.

so i am looking for a good lead in the right direction. surely, google has many. but, that is what makes it so bad. google can show you dozens of wrong ways to do something.

edit:

oops! there is no os.poll.
I would use multiprocessing to
Quote:Start a process to read from 2 (or more) pipes
and read from the second pipe from the program. Provide an example if you want more specific info.
i have no example, yet. i am doing planning first. but, i will focus on multiprocessing. thanks for the lead.