On Jul 30, 7:30 pm, Jonathan Gardner
wrote:
> On Jul 30, 5:24 pm, Dhanesh wrote:
>
>
>
> > how can I we have a non blocking read ?
>
> Seehttp://docs.python.org/library/popen2.html#flow-control-issues
>
> Note well: In the non-blocking world, you have to use select() or poll
> () to get your job
Hello,
According to my experience and from what I've read in other threads,
subprocess isn't easy to use for interactive tasks. I don't really
know, but maybe it wasn't even designed for that at all.
On the other hand, pexpect seems to work fine for interactive use and
even provides a method for
> Jonathan Gardner (JG) wrote:
>JG> On Jul 30, 5:24 pm, Dhanesh wrote:
>>>
>>> how can I we have a non blocking read ?
>JG> See http://docs.python.org/library/popen2.html#flow-control-issues
>JG> Note well: In the non-blocking world, you have to use select() or poll
>JG> () to get your jo
On Jul 30, 5:24 pm, Dhanesh wrote:
>
> how can I we have a non blocking read ?
See http://docs.python.org/library/popen2.html#flow-control-issues
Note well: In the non-blocking world, you have to use select() or poll
() to get your job done.
You may want to look at "communicate" (http://docs.py
You can always have a thread which continually reads stdin and stores it
in a string, or better, in a cStringIO.StringIO object. Then in the main
thread, you can check whether something new has arrived. This, of course
will work on all platforms.
I hope this helped a bit,
Noam
--
http://mail.py
Donn Cave wrote:
Yes, this looks right to me, but I think we're talking
about os.read(), not fileobject.read().
Indeed, you shouldn't be mixing select() with buffered
io, or all kinds of bad things can happen.
Everything I said applies to OS-level reads and
writes, not stdio-level ones.
--
Greg Ewi
In article <[EMAIL PROTECTED]>,
Greg Ewing <[EMAIL PROTECTED]> wrote:
> Donn Cave wrote:
> > If we are indeed talking about a pipe or something that
> > really can block, and you call fileobject.read(1024),
> > it will block until it gets 1024 bytes.
>
> No, it won't, it will block until *some*
Gustavo Córdova Avila wrote:
Steve Holden wrote:
Gustavo Córdova Avila wrote:
Actually the op did mention that he wanted to monitor files.
As was pointed out to me when I made the same assertion, he actually
said "file object which is stdin" or something like that, which means
the object could b
Steve Holden wrote:
Gustavo Córdova Avila wrote:
Actually the op did mention that he wanted to monitor files.
As was pointed out to me when I made the same assertion, he actually
said "file object which is stdin" or something like that, which means
the object could be a socket, a pipe, a file, a
Gustavo Córdova Avila wrote:
Donn Cave wrote:
Depends. I don't believe the original post mentioned
that the file is a pipe, socket or similar, but it's
kind of implied by the use of select() also mentioned.
It's also kind of implied by use of the term "block" -
disk files don't block.
If we are in
Donn Cave wrote:
Depends. I don't believe the original post mentioned
that the file is a pipe, socket or similar, but it's
kind of implied by the use of select() also mentioned.
It's also kind of implied by use of the term "block" -
disk files don't block.
If we are indeed talking about a pipe or
Steve Holden a écrit :
Donn Cave wrote:
In article <[EMAIL PROTECTED]>,
Gustavo Córdova Avila <[EMAIL PROTECTED]> wrote:
David Bolen wrote:
Jp Calderone <[EMAIL PROTECTED]> writes:
def nonBlockingReadAll(fileObj):
bytes = []
while True:
b = fileObj.read(1024)
Steve Holden wrote:
When access is made to a file object in
non-blocking mode it will return whatever data there are immediately
available in the buffers, up to the number of bytes requested. If the
buffers are currently empty the process will generate an error
Are you sure that's right? If so,
Donn Cave wrote:
If we are indeed talking about a pipe or something that
really can block, and you call fileobject.read(1024),
it will block until it gets 1024 bytes.
No, it won't, it will block until *some* data is
available, and then return that (up to a maximum of
1024).
If the fd has just been
Donn Cave wrote:
In article <[EMAIL PROTECTED]>,
Gustavo Córdova Avila <[EMAIL PROTECTED]> wrote:
David Bolen wrote:
Jp Calderone <[EMAIL PROTECTED]> writes:
def nonBlockingReadAll(fileObj):
bytes = []
while True:
b = fileObj.read(1024)
bytes.append(b)
In article <[EMAIL PROTECTED]>,
Gustavo Córdova Avila <[EMAIL PROTECTED]> wrote:
> David Bolen wrote:
>
> >Jp Calderone <[EMAIL PROTECTED]> writes:
> >
> >>def nonBlockingReadAll(fileObj):
> >>bytes = []
> >>while True:
> >>b = fileObj.read(1024)
> >>
David Bolen wrote:
Jp Calderone <[EMAIL PROTECTED]> writes:
def nonBlockingReadAll(fileObj):
bytes = []
while True:
b = fileObj.read(1024)
bytes.append(b)
if len(b) < 1024:
break
return ''.join(bytes)
Wouldn't this still block
On 01 Dec 2004 15:55:18 -0500, David Bolen <[EMAIL PROTECTED]> wrote:
>Jp Calderone <[EMAIL PROTECTED]> writes:
>
> > def nonBlockingReadAll(fileObj):
> > bytes = []
> > while True:
> > b = fileObj.read(1024)
> > bytes.append(b)
> > if len(b)
Jp Calderone <[EMAIL PROTECTED]> writes:
> def nonBlockingReadAll(fileObj):
> bytes = []
> while True:
> b = fileObj.read(1024)
> bytes.append(b)
> if len(b) < 1024:
> break
> return ''.join(bytes)
Wouldn't this still
In article <[EMAIL PROTECTED]>,
Uwe Mayer <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I use select() to wait for a file object (stdin) to become readable. In that
> situation I wanted to read everything available from stdin and return to
> the select statement to wait for more.
>
> However, the file o
On Wed, 01 Dec 2004 19:39:45 +0100, Uwe Mayer <[EMAIL PROTECTED]> wrote:
>Hi,
>
> I use select() to wait for a file object (stdin) to become readable. In that
> situation I wanted to read everything available from stdin and return to
> the select statement to wait for more.
>
> However, the file
21 matches
Mail list logo