On Tuesday, 27 September 2022 at 03:22:47 UTC-6 dim...@gmail.com wrote: > On Tue, Sep 27, 2022 at 3:58 AM Andrey Novoseltsev <novo...@gmail.com> > wrote: > > this temporary directory is created and then used ever after. But what > if it gets deleted? > I think it's meant to be used in a context manager, i.e. with with > statement, e.g., citing python docs: > > >>> with tempfile.TemporaryDirectory() as tmpdirname: > ... print('created temporary directory', tmpdirname) > >>> > # directory and contents have been removed > > Or with a callback (from Sage source) > > TMP_DIR_FILENAME_BASE=tempfile.TemporaryDirectory() > atexit.register(lambda: TMP_DIR_FILENAME_BASE.cleanup()) > > > Needless to say, one can interfere with it in a bad way messing around > with ~/.sage/ - but so it the case for any file-based process... > > It seems to me like a pretty common and sensible practice, that /tmp directories get cleaned up, especially on systems with lots of activity. I would not consider it as "a bad way messing around". But creating a temporary directory and then counting on it being there hours later for another quick temporary operation may be a bit too optimistic. That callback is designed to clean up after Sage quits, which is a good thing to do, but it is not related to being able to use the directory.
-- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/231e405f-3af0-4a23-808e-0fb5edeb89bcn%40googlegroups.com.