python - can't delete a file after no space left on device -


i'm writing bunch of files on several hard disks. files don't fit on single hard drive write on next 1 if first 1 out of space. catch ioerror 28 figure out.

my exact problem when try remove last file written (incomplete file) first disk new exception don't understand. seems with-block can't close file because there no space left on disk.

i'm on windows , disks formatted ntfs.

could please me.

# here's sample code # recommend first fill disk full large dummy file. # on windows create dummy file #   'fsutil file createnew large.txt 1000067000000'  import os import errno  fill = 'j:/fill.txt' try:     open(fill, 'wb') f:         while true:             n = f.write(b"\0") except ioerror e:     if e.errno == errno.enospc:         os.remove(fill) 

here's traceback:

traceback (most recent call last):   file "nospacelef.py", line 8, in <module>     n = f.write(b"\0") ioerror: [errno 28] no space left on device  during handling of above exception, exception occurred:  traceback (most recent call last):   file "nospacelef.py", line 8, in <module>     n = f.write(b"\0") ioerror: [errno 28] no space left on device  during handling of above exception, exception occurred:  traceback (most recent call last):   file "nospacelef.py", line 11, in <module>     os.remove(fill) windowserror: [error 32] process cannot access file because being used process: 'j:/fill.txt' 

answering own question.

i filed bug python [1][2]. fixed in 3.3+. there no fix 3.2 used. upgraded python version i'm not suffering problem anymore.

[1] http://bugs.python.org/issue25202

[2] http://bugs.python.org/issue16597


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -