[socal-piggies] weird behavior with files on different filesystems

kohler at netrino.com kohler at netrino.com
Fri Mar 7 12:15:23 PST 2008


> However, if I make a unique temp file in /tmp using tempfile.mkstemp,
> and then copy it into place, then some (but not all) of the resulting
> files are 0 size, and many or all of the remaining ones are truncated
> without a trailing newline.

You are missing the trailing parentheses here:

        tmpfile.close


By leaving out the parentheses, you're not calling close; you've just
created a callable expression that doesn't do anything. As a result, when
you move the file, there is a race condition. The contents of the new file
may still be in buffers and not actually written to the file yet when you
call the move routine.


Mark





More information about the socal-piggies mailing list