Re: Imitating "tail -f"

2009-11-30 Thread exarkun
On 11:15 am, p...@boddie.org.uk wrote: On 22 Nov, 05:10, exar...@twistedmatrix.com wrote: "tail -f" is implemented by sleeping a little bit and then reading to see if there's anything new. This was the apparent assertion behind the "99 Bottles" concurrency example: http://wiki.python.org/moi

Re: Imitating "tail -f"

2009-11-30 Thread Paul Boddie
On 22 Nov, 05:10, exar...@twistedmatrix.com wrote: > > "tail -f" is implemented by sleeping a little bit and then reading to > see if there's anything new. This was the apparent assertion behind the "99 Bottles" concurrency example: http://wiki.python.org/moin/Concurrency/99Bottles However, as I

Re: Imitating "tail -f"

2009-11-28 Thread Aahz
In article , Matt Nordhoff wrote: >Jason Sewall wrote: >> >> FWIW, GNU tail on Linux uses inotify for tail -f: > >Some other operating systems have similar facilities, e.g. FSEvents on OS X. Having spent some time with FSEvents, I would not call it particularly similar to inotify. FSEvents only

Re: Imitating "tail -f"

2009-11-22 Thread Nobody
On Sun, 22 Nov 2009 03:43:31 +0100, Ivan Voras wrote: > The problem is: poll() always returns that the fd is ready (without > waiting), but read() always returns an empty string. Actually, it > doesn't matter if I turn O_NDELAY on or off. select() does the same. Regular files are always "ready" f

Re: Imitating "tail -f"

2009-11-22 Thread Paul Rudin
Matt Nordhoff writes: > Jason Sewall wrote: >> FWIW, GNU tail on Linux uses inotify for tail -f: >> >> http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/tail.c >> >> The wikipedia page for inotify lists several python bindings: >> >> http://en.wikipedia.org/wiki/Inotify >> >> Not much h

Re: Imitating "tail -f"

2009-11-22 Thread Wolodja Wentland
On Sun, Nov 22, 2009 at 03:43 +0100, Ivan Voras wrote: > I'm trying to simply imitate what "tail -f" does, i.e. read a file, wait > until it's appended to and process the new data, but apparently I'm > missing something. [..] > Any advice? Have a look at [1], which mimics "tail -f" perfectly. It c

Re: Imitating "tail -f"

2009-11-21 Thread Matt Nordhoff
Jason Sewall wrote: > FWIW, GNU tail on Linux uses inotify for tail -f: > > http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/tail.c > > The wikipedia page for inotify lists several python bindings: > > http://en.wikipedia.org/wiki/Inotify > > Not much help for non-Linux users, but there

Re: Imitating "tail -f"

2009-11-21 Thread Jason Sewall
FWIW, GNU tail on Linux uses inotify for tail -f: http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/tail.c The wikipedia page for inotify lists several python bindings: http://en.wikipedia.org/wiki/Inotify Not much help for non-Linux users, but there it is. Too bad, because inotify is pre

Re: Imitating "tail -f"

2009-11-21 Thread exarkun
On 02:43 am, ivo...@gmail.com wrote: I'm trying to simply imitate what "tail -f" does, i.e. read a file, wait until it's appended to and process the new data, but apparently I'm missing something. The code is: 54 f = file(filename, "r", 1) 55 f.seek(-1000, os.SEEK_END) 56 ff = fcnt

Imitating "tail -f"

2009-11-21 Thread Ivan Voras
I'm trying to simply imitate what "tail -f" does, i.e. read a file, wait until it's appended to and process the new data, but apparently I'm missing something. The code is: 54 f = file(filename, "r", 1) 55 f.seek(-1000, os.SEEK_END) 56 ff = fcntl.fcntl(f.fileno(), fcntl.F_GETFL) 5