Re: read stdout/stderr without blocking
Please note that popen uses pipes, which are block devices, not character devices, so the writes will be done in blocks instead of characters/lines, (you can only read something _after_ the application at the other end of the pipe has done a flush or written 8192 bytes.
When reading from a pty like pexpect does, your read will not block until the stdio block buffer is filled.
Maybe using popen is your problem? The FAQ of Pexpect explains the problem very clearly.
>>>Jacek Pop*awski <email@example.com> 09/13/05 4:36 pm >>>
|Grant Edwards wrote:
|>You're right. I must have been remembering the behavior of a
|>network socket. Apparently, you're supposed to read a single
|>byte and then call select() again. That seems pretty lame.
|I created another thread with single read(), it works, as long as I have
| only one PIPE (i.e. stderr is redirected into stdout).
|I wonder is it Python limitation or systems one (I need portable solution)?
|All times are GMT. The time now is 02:50 PM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.