Skip to content

Commit

Permalink
Merge pull request #165 from vhernando/delete_tempfile
Browse files Browse the repository at this point in the history
Delete temporary file
  • Loading branch information
peter-wangxu authored Feb 10, 2022
2 parents d302298 + d638b6d commit d6ed33d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion persistqueue/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def __init__(self, path, maxsize=0, chunksize=100, tempdir=None,
raise ValueError("tempdir has to be located "
"on same path filesystem")
else:
_, tempdir = tempfile.mkstemp()
fd, tempdir = tempfile.mkstemp()
if os.stat(self.path).st_dev != os.stat(tempdir).st_dev:
self.tempdir = self.path
log.warning("Default tempdir '%(dft_dir)s' is not on the "
Expand All @@ -105,6 +105,9 @@ def __init__(self, path, maxsize=0, chunksize=100, tempdir=None,
"dft_dir": tempdir,
"queue_path": self.path,
"new_path": self.tempdir})
os.close(fd)
os.remove(tempdir)

self.info = self._loadinfo()
# truncate head case it contains garbage
hnum, hcnt, hoffset = self.info['head']
Expand Down

0 comments on commit d6ed33d

Please sign in to comment.