Blocking read on pipes

Discussion in 'Python' started by =?iso-8859-1?Q?Arnau_S=E1nchez?=, Jul 15, 2004.

  1. Hello,

    I have a problem when reading from stdin (using it as pipe) in a Python program (the sender
    is written in C):

    C (sender)
    write(1, buffer, 4)

    Python (recv.py)
    sys.stdin.read(256) or sys.stdin.read()

    sender | recv.py

    Python's read blocks the program because the written buffer length (4) is lower than the indicated
    in read function (256), but when I do the same with C (read(0, buffer, 256)) it is not blocking,
    just
    returns the four bytes. That is what I need.

    I've tried to flush the stdout in the sending program, but it does the same.

    any ideas?

    thanks,
    arnau
    =?iso-8859-1?Q?Arnau_S=E1nchez?=, Jul 15, 2004
    #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. Hendra Gunawan
    Replies:
    1
    Views:
    12,430
    Allan Herriman
    Apr 8, 2004
  2. Tom Plunket
    Replies:
    3
    Views:
    740
    Donn Cave
    Jan 9, 2007
  3. Serge Savoie
    Replies:
    4
    Views:
    256
    Serge Savoie
    Oct 1, 2008
  4. Sébastien Cottalorda

    Pipes and non blocking writing

    Sébastien Cottalorda, Apr 20, 2004, in forum: Perl Misc
    Replies:
    2
    Views:
    194
    Sébastien Cottalorda
    Apr 20, 2004
  5. john
    Replies:
    7
    Views:
    233
    Brian McCauley
    Mar 4, 2005
Loading...

Share This Page