Re: read stdout/stderr without blocking

Discussion in 'Python' started by Adriaan Renting, Sep 14, 2005.

  1. 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 <> 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)?
    --
    http://mail.python.org/mailman/listinfo/python-list
    Adriaan Renting, Sep 14, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?ISO-8859-2?Q?Jacek_Pop=B3awski?=

    read stdout/stderr without blocking

    =?ISO-8859-2?Q?Jacek_Pop=B3awski?=, Sep 12, 2005, in forum: Python
    Replies:
    1
    Views:
    3,985
    =?ISO-8859-2?Q?Jacek_Pop=B3awski?=
    Sep 13, 2005
  2. Adriaan Renting

    Re: read stdout/stderr without blocking

    Adriaan Renting, Sep 12, 2005, in forum: Python
    Replies:
    1
    Views:
    328
    =?UTF-8?B?SmFjZWsgUG9wxYJhd3NraQ==?=
    Sep 12, 2005
  3. Adriaan Renting

    Re: read stdout/stderr without blocking

    Adriaan Renting, Sep 12, 2005, in forum: Python
    Replies:
    10
    Views:
    670
    =?ISO-8859-2?Q?Jacek_Pop=B3awski?=
    Sep 16, 2005
  4. Adriaan Renting

    Re: read stdout/stderr without blocking

    Adriaan Renting, Sep 16, 2005, in forum: Python
    Replies:
    0
    Views:
    378
    Adriaan Renting
    Sep 16, 2005
  5. George C. Demetros

    BLOCKING and STDOUT/STDERR

    George C. Demetros, Jan 6, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    93
    Ben Morrow
    Jan 6, 2004
Loading...

Share This Page