Problems with select
Neal Norwitz
neal at metaslash.com
Tue Feb 26 08:02:06 EST 2002
Alain Tesio wrote:
>
> Hi, I can't manage to make select work, in both 1.52 and 2.1.2
>
> I just want to read stderr and stdout when executing a command
> with popen3, and I must use select, read() blocks when there is
> more than a fixed amount of data (4 KB I think)
>
> The problems is that select still gives something after the end
> of the file, or sometimes never returns anything at all.
>
> I create the pipes with :
>
> (pipe_out,pipe_in,pipe_err)=popen2.popen3(command)
>
> and use select like this:
>
> pollstatus=select.select([],[pipe_out],[pipe_err],1)
>
> (the doc says : select(iwtd, owtd, ewtd[, timeout])
> I didn't put pipe_in as it's closed)
It looks like you may want to do something like:
select_fds = [ pipe_out, pipe_err ]
pollstatus=select.select(select_fds,[],[],1)
select() should return whenever there is something to read from
either pipe_out or pipe_err, or after 1 second.
Neal
More information about the Python-list
mailing list