Pipe problem

Discussion in 'Python' started by Doug, Sep 13, 2003.

  1. Doug

    Doug Guest

    This works with a small string, but not a large one (read returns an
    empty string if i pass a large html file to tidy):


    >>> iin , iiout = popen2("tidy.exe -asxml")
    >>> iin.write(str)
    >>> iin.close()
    >>> iiout.read()

    ''

    I am using windows and tried the standard pipe and win32pipe as well.

    Doug
     
    Doug, Sep 13, 2003
    #1
    1. Advertising

  2. On Sat, 13 Sep 2003 16:34:13 GMT, Doug <> wrote:
    > This works with a small string, but not a large one (read returns an
    > empty string if i pass a large html file to tidy):
    >
    >
    > >>> iin , iiout = popen2("tidy.exe -asxml")
    > >>> iin.write(str)
    > >>> iin.close()
    > >>> iiout.read()

    > ''
    >
    > I am using windows and tried the standard pipe and win32pipe as well.


    Probably the standard pipe buffering problem.

    As you know computer systems have a finite amount of memory, which is
    used for many things, including buffering data written to a pipe.

    The write(str) returns when you have written the entire contents out.
    Since it is big, and tidy.exe also uses finite buffering, the latter
    starts processing and returning data while you are writing. Since you
    are not reading incoming data, the pipe in the other direction gets
    full, tidy.exe becomes blocked, which in turn means your write() becomes
    blocked.

    Solution: read and write at the same time.


    Albert
    --
    Unlike popular belief, the .doc format is not an open publically available format.
     
    Albert Hofkamp, Sep 16, 2003
    #2
    1. Advertising

  3. Doug

    John J. Lee Guest

    Albert Hofkamp <> writes:

    > On Sat, 13 Sep 2003 16:34:13 GMT, Doug <> wrote:
    > > This works with a small string, but not a large one (read returns an
    > > empty string if i pass a large html file to tidy):
    > >
    > >
    > > >>> iin , iiout = popen2("tidy.exe -asxml")
    > > >>> iin.write(str)
    > > >>> iin.close()
    > > >>> iiout.read()

    [...]

    Didn't see the OP, but (guessing tidy.exe is HTMLTidy): do you know
    about mxTidy and uTidylib?


    John
     
    John J. Lee, Sep 16, 2003
    #3
    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. richard

    named pipe problem on linux

    richard, Nov 1, 2004, in forum: C++
    Replies:
    5
    Views:
    1,034
    Sybren Stuvel
    Nov 2, 2004
  2. lee, wonsun
    Replies:
    1
    Views:
    505
    Jack Klein
    Nov 2, 2004
  3. Chris S.

    Pipe IO Problem?

    Chris S., Sep 6, 2004, in forum: Python
    Replies:
    1
    Views:
    332
    Donn Cave
    Sep 7, 2004
  4. GerShar
    Replies:
    1
    Views:
    754
    Dennis Lee Bieber
    Oct 31, 2005
  5. Replies:
    1
    Views:
    248
    Ben Morrow
    Jun 2, 2004
Loading...

Share This Page