On 15Nov2010 20:47, MRAB <pyt...@mrabarnett.plus.com> wrote:
| On 15/11/2010 11:03, Ton wrote:
| >Hi Mrab,
| >  Thanks for your immediate reply , can you please guide me with any
| >tool or library function which i can flush my fifo content .. i use
| >os.mkfifo() to make the fifo. Or is there any other way i could do
| >this ...
| >Thanks
| 
| Ah, you're using pipes; I thought you might've been using a queue. I
| don't know of a way of flushing a pipe.

I think the nearest thing you can do is empty it with a read().
On many systems (AFAIR) a stat of a pipe returns the amount of buffered
data, so you could go (untested - some of the following method names
will probably be wrong, too) something like:

  buffered = os.fstat(fifo.fileno())
  if buffered > 0:
    fifo.read(buffered)

Of course it is all a bit racy, as data may arrive after the stat,
but arbitrarily "flush"ing the pipe has equivalent problems.

| I wonder whether it's a good idea for the producer to keep filling the
| fifo, because the consumer know how 'old' the info is when it arrives,
| and there's your problem of discarding stale info. Perhaps the producer
| should wait until the consumer has sent an acknowledgement before
| sending more info.

I agree with this statement.
-- 
Cameron Simpson <c...@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

In the end, winning is the only safety. - Kerr Avon
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to