Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Pipe problem

Reply
Thread Tools

Pipe problem

 
 
Doug
Guest
Posts: n/a
 
      09-13-2003
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

 
Reply With Quote
 
 
 
 
Albert Hofkamp
Guest
Posts: n/a
 
      09-16-2003
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.
 
Reply With Quote
 
 
 
 
John J. Lee
Guest
Posts: n/a
 
      09-16-2003
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem: Windows Command line Pipe to stdin GerShar Python 1 10-31-2005 02:24 AM
named pipe problem on linux richard C++ 5 11-02-2004 07:44 PM
[named pipe] i wanna know about validate of pipe handle of client lee, wonsun C++ 1 11-02-2004 04:29 AM
Pipe IO Problem? Chris S. Python 1 09-07-2004 06:00 PM
Why does IO::Pipe::END generate an EXCEPT pipe message? lvirden@gmail.com Perl Misc 1 06-02-2004 02:17 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57