island: Can't use `with` with `os.open()`, use `os.close()` to close file descriptor

This commit is contained in:
Shreya 2021-06-14 17:07:30 +05:30
parent 8b932e1946
commit 5fe0c80377
1 changed files with 1 additions and 3 deletions

View File

@ -62,9 +62,7 @@ def _create_secure_file_linux(path: str):
os.O_RDWR | os.O_CREAT | os.O_EXCL
) # read/write, create new, throw error if file exists
mode = 0o700 # read/write/execute permissions to owner
with os.open(path, flags, mode) as x: # noqa: F841
pass
os.close(os.open(path, flags, mode))
except Exception as ex:
LOG.error(f'Could not create a file at "{path}": {str(ex)}')