Following a file, or cloning tail
Gordon McMillan
gmcm at hypernet.com
Thu Jun 29 19:28:56 EDT 2000
[posted and mailed]
Cameron Laird gets his tail in a knot:
>Gordon McMillan <gmcm at hypernet.com> wrote:
>>Um, you said you had to be portable. Not only is tail not standard on
>>Windows, but os.popen is flaky there too (depending on circumstances
>>too painful to enumerate).
>I think I'm going to start growling every time
>I hear that. To be precise: popen* flakiness
>is one of the chief discouragements in my use
>of Python (which is, I recognize, slightly
>skewed from other's).
Well, os.popen works fine between console processes on the NT family of
Windows. However, Windows has problems with 16 bit DOS apps and Win95 has
an MS acknowledged problem with any of this stuff. The win32 extensions fix
most of these problems, (I think Bill Tutt even added a workaround for the
Win95 bug), and I believe that 1.6 will use the win32 versions if they are
installed (at least, this was discussed seriously at some point).
>>However, tail (usually - some implementations differ) does almost what
>>the following code does. Note that even this isn't portable, because
>>Windows doesn't have ino's to check. I have the code this is extracted
>>from 7x24
>Guys, guys: there are enough seriously hard
>problems in the world. Don't make this one.
>
>Win* FSs don't have i-nodes. So a portable
>formulation of the requirements shouldn't
>involve i-node. That's OK. Just poll for
>either readability or file size. While I
>confess I haven't verified that Py-built-ins
>for these are properly portable, they REALLY
>need to be if they aren't already, and I'm
>willing to write test drivers and demonstra-
>tions if these remain in doubt for one more
>round of c.l.p dialogue.
The whole inode thing in that code is because it is a common Linux idiom to
rely on the fact that once a process has opened a file, said file can be
deleted by another process without the reading process noticing.
This idiom is completely impossible on Windows, so there's no sense in
checking whether a new file with the same name has now been created.
So what'll it be - a portable version that's useless on Linux, or one that
spends half it's time checking for something that can't occur on Windows
<wink>?
on-Windows-once-you've-grabbed-the-tail-
you've-got-the-whole-damn-dog-ly y'rs
- Gordon (who never uses popen on Windows anyway)
More information about the Python-list
mailing list