Skip to content

Commit 69fb190

Browse files
committed
Add TempFS.close docstring with a warning about the auto_clean parameter
1 parent b95adcb commit 69fb190

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

fs/tempfs.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,28 @@ def __str__(self):
7171

7272
def close(self):
7373
# type: () -> None
74+
"""Close the filesystem and release any resources.
75+
76+
It is important to call this method when you have finished
77+
working with the filesystem. Some filesystems may not finalize
78+
changes until they are closed (archives for example). You may
79+
call this method explicitly (it is safe to call close multiple
80+
times), or you can use the filesystem as a context manager to
81+
automatically close.
82+
83+
Hint:
84+
Depending on the value of ``auto_clean`` passed when creating
85+
the `TempFS`, the underlying temporary folder may be removed
86+
or not.
87+
88+
Example:
89+
>>> tmp_fs = TempFS(auto_clean=False)
90+
>>> syspath = tmp_fs.getsyspath("/")
91+
>>> tmp_fs.close()
92+
>>> os.path.exists(syspath)
93+
True
94+
95+
"""
7496
if self._auto_clean:
7597
self.clean()
7698
super(TempFS, self).close()

0 commit comments

Comments
 (0)