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(
#
>
> I observed that python scripts blocks at stdout read on the other hand
> when I do not create a child stdout PIPE say " stdout=None" , things
> seems to be working fine.
>
> how can I we have a non blocking read ?
> And why does stdout blo
>>>>> 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, y
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 "communi
##
I observed that python scripts blocks at stdout read on the other hand
when I do not create a child stdout PIPE say " stdout=None" , things
seems to be working fine.
how can I we have a non blocking read ?
And why does stdout block even where data is available to be
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
Hi
Can any one help.
I am trying to write a python scipt that takes input as args and/or as piped
input ( possibly the output of another program).
I want to read stdin ( the piped in stuuff ) whcih might be empty without
the script blocking if it is empty.
I understand it is possible to do unde
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
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 object's read method blocks if the number of bytes is 0 or
negative.
Is there no way
24 matches
Mail list logo