Pipe problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Doug

    Pipe problem

    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):

    [color=blue][color=green][color=darkred]
    >>> iin , iiout = popen2("tidy.ex e -asxml")
    >>> iin.write(str)
    >>> iin.close()
    >>> iiout.read()[/color][/color][/color]
    ''

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

    Doug

  • Albert Hofkamp

    #2
    Re: Pipe problem

    On Sat, 13 Sep 2003 16:34:13 GMT, Doug <no.email.you.m ust.phone.me@fu .bar.ws> wrote:[color=blue]
    > 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):
    >
    >[color=green][color=darkred]
    > >>> iin , iiout = popen2("tidy.ex e -asxml")
    > >>> iin.write(str)
    > >>> iin.close()
    > >>> iiout.read()[/color][/color]
    > ''
    >
    > I am using windows and tried the standard pipe and win32pipe as well.[/color]

    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.

    Comment

    • John J. Lee

      #3
      Re: Pipe problem

      Albert Hofkamp <hat@se-126.se.wtb.tue. nl> writes:
      [color=blue]
      > On Sat, 13 Sep 2003 16:34:13 GMT, Doug <no.email.you.m ust.phone.me@fu .bar.ws> wrote:[color=green]
      > > 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):
      > >
      > >[color=darkred]
      > > >>> iin , iiout = popen2("tidy.ex e -asxml")
      > > >>> iin.write(str)
      > > >>> iin.close()
      > > >>> iiout.read()[/color][/color][/color]
      [...]

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


      John

      Comment

      Working...