Merge pull request #40418 from lorengordon/close-temp-file

Closes handle to temporary file before returning the path
This commit is contained in:
Mike Place 2017-03-30 16:22:02 -06:00 committed by GitHub
commit 1f5d6b88f9

View file

@ -10,6 +10,7 @@ This is a thin wrapper around Pythons tempfile module
from __future__ import absolute_import
import logging
import os
import tempfile
log = logging.getLogger(__name__)
@ -40,4 +41,6 @@ def file(suffix='', prefix='tmp', parent=None):
salt '*' temp.file
salt '*' temp.file prefix='mytemp-' parent='/var/run/'
'''
return tempfile.mkstemp(suffix, prefix, parent)[1]
fh_, tmp_ = tempfile.mkstemp(suffix, prefix, parent)
os.close(fh_)
return tmp_