bug in file.write() ?

Bengt Richter bokr at oz.net
Sat Aug 2 12:34:58 EDT 2003


On Sat, 02 Aug 2003 10:37:48 +0200, Patrick Useldinger <pu at vo.lu> wrote:

>Bengt Richter wrote:
[Actually this is not the part I (Bengt) wrote, though I agree
 that a file.write bug per se is unlikely ;-)]
>>>This is very unlikely --- it is difficult to determine reliably the
>>>available space on a disk or tape volume; if one were really
>>>interested, one would do it once before trying to write the file, not
>>>before writing each block. No, the expected implementation, which you
>>>can check against reality by inspecting the source (fileobject.c), is
>>>just to attempt to write, and throw an informative-as-possible
>>>exception if the write fails.
>
>This is actually a CD-RW, and it has no files on it. I have used that 
>very same CD earlier, and was able to fill it to its max.
>
>>>Despite the appearance that you have about 6KB margin of safety,  you
>
>The margin is 50%, or 299 000 000 bytes, as you can see below. If I copy 
>the file via the NT Explorer, it works ok, so the CD-RW is not the problem.
>
Sorry, I didn't really read your traceback. I went with the "6kb" ;-)
I wonder if 1) the error message is for real or is another error condition
improperly reported, 2) whether you are in a threaded situation where some
kind of race condition could be involved, or 3) whether you could be
getting buffer underrun as the real cause for (1), and (4) can you reformat
(as opposed to deleting files) the CDRW or use a fresh blank and get the same
problem? Perhaps there could be a fragmentation problem?

Is the CD-RW set up to look like an ordinary disk to applications?
If so, you could try (note file extension ;-)

    f=file('f:\dfcArchive cheetah 20030731-234648 F.zip_fake', 'wb')
    million = '-'*(1000*1000)
    rest = '+'*630592
    for m in range(299):
        f.write(million)
    f.write(rest)
    f.close()

And see if that gets there. Those are big chunks with no disk read delays,
vs shutil's 16k read-source/write-dest loop. This might give a clue for
chasing underrun or other timing problems.

If there is contention for the the CDRW between threads or processes somehow,
maybe you have to arrange for a single writer fed by a queue or such?

Hope this gives you a useful idea.

Regards,
Bengt Richter




More information about the Python-list mailing list