Message175616
Exceptions such as disk full during extraction cause tarfile to leak file handles. Besides being messy, it causes real problems if, for example, the target file is on a mount that should be unmounted before the program exits - in this case, the unmount will fail as there are still open file handles.
Simplest solution I can see is to change:
def makefile(self, tarinfo, targetpath):
"""Make a file called targetpath.
"""
source = self.extractfile(tarinfo)
target = bltn_open(targetpath, "wb")
copyfileobj(source, target)
source.close()
target.close()
to this:
def makefile(self, tarinfo, targetpath):
"""Make a file called targetpath.
"""
source = self.extractfile(tarinfo)
try:
with open(targetpath, "wb") as target:
shutil.copyfileobj(source, target)
finally:
source.close() |
|
Date |
User |
Action |
Args |
2012-11-15 12:49:47 | ssam | set | recipients:
+ ssam |
2012-11-15 12:49:47 | ssam | set | messageid: <1352983787.27.0.404679122442.issue16477@psf.upfronthosting.co.za> |
2012-11-15 12:49:47 | ssam | link | issue16477 messages |
2012-11-15 12:49:46 | ssam | create | |
|