Add parameter to fs_cleanup function to close a file descriptor before closing it. GitLab issue #309.
This commit is contained in:
@@ -45,10 +45,13 @@ def encapsulate(function):
|
||||
return lambda: function
|
||||
|
||||
|
||||
def fs_cleanup(filename, suppress_exceptions=True):
|
||||
def fs_cleanup(filename, file_descriptor=None, suppress_exceptions=True):
|
||||
"""
|
||||
Tries to remove the given filename. Ignores non-existent files
|
||||
"""
|
||||
if file_descriptor:
|
||||
os.close(file_descriptor)
|
||||
|
||||
try:
|
||||
os.remove(filename)
|
||||
except OSError:
|
||||
|
||||
Reference in New Issue
Block a user