Skip to content

Commit

Permalink
Add distinctive prefixes to tempfiles to aid finding resource leaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Feb 28, 2013
1 parent bd50a59 commit 79bcc42
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ZODB/Connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ def __init__(self, storage):
):
setattr(self, method, getattr(storage, method))

self._file = tempfile.TemporaryFile()
self._file = tempfile.TemporaryFile(prefix='TmpStore')
# position: current file position
# _tpos: file position at last commit point
self.position = 0
Expand Down
2 changes: 1 addition & 1 deletion src/ZODB/ExportImport.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ExportImport:

def exportFile(self, oid, f=None):
if f is None:
f = TemporaryFile()
f = TemporaryFile(prefix="EXP")
elif isinstance(f, six.string_types):
f = open(f,'w+b')
f.write(b'ZEXP')
Expand Down
4 changes: 2 additions & 2 deletions src/ZODB/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ def get_pickle_metadata(data):
classname = ''
return modname, classname

def mktemp(dir=None):
def mktemp(dir=None, prefix='tmp'):
"""Create a temp file, known by name, in a semi-secure manner."""
handle, filename = mkstemp(dir=dir)
handle, filename = mkstemp(dir=dir, prefix=prefix)
os.close(handle)
return filename

Expand Down

0 comments on commit 79bcc42

Please sign in to comment.