Maxmium bufsize using open2?

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

    Maxmium bufsize using open2?

    Dear all,

    I've a problem using popen2 when using large files.
    When I use small input files everything works well but when I feed large
    inputfile to the pipe nothing happens. Is there a maximum bufsize for
    using the pipe. The code I use is written down here below. Do I need to
    specify a waittime between line 4 and 5 ?


    o,i =popen2('comman d '))
    fh=open(os.path .join(self.dirn ame, self.filename), 'r')
    i.write(fh.read ())
    i.close()
    self.StringData =o.read()
    o.close()


  • Thomas Güttler

    #2
    Re: Maxmium bufsize using open2?

    Maurice wrote:
    [color=blue]
    > Dear all,
    >
    > I've a problem using popen2 when using large files.
    > When I use small input files everything works well but when I feed large
    > inputfile to the pipe nothing happens. Is there a maximum bufsize for
    > using the pipe. The code I use is written down here below. Do I need to
    > specify a waittime between line 4 and 5 ?
    >
    >
    > o,i =popen2('comman d '))
    > fh=open(os.path .join(self.dirn ame, self.filename), 'r')
    > i.write(fh.read ())
    > i.close()
    > self.StringData =o.read()
    > o.close()[/color]

    Hi,

    Have a look at the select module.

    thomas

    Comment

    • Piet van Oostrum

      #3
      Re: Maxmium bufsize using open2?

      As someone else already mentioned, using select is another solution.
      All solution amount to the fact the input and output to the process are
      interleaved.
      --
      Piet van Oostrum <piet@cs.uu.n l>
      URL: http://www.cs.uu.nl/~piet [PGP]
      Private email: P.van.Oostrum@h ccnet.nl

      Comment

      Working...