Message390911
> So we stop passing the O_TEMPORARY flag. If __enter__() is called,
> close() closes the file but doesn't delete anything, and
> __exit__() closes the file (if open) and deletes it (even if it
> wasn't open). If there is no __enter__(), close() also deletes the
> file.
This behavior change is fine if O_TEMPORARY isn't used. I wasn't disagreeing with Ethan. I was providing a summary of a common use case that conflicts with using O_TEMPORARY to make it clear that this flag has to be omitted if we're not implementing something like a delete_on_close boolean option.
Most of my last comment, however, was dedicated to implementing TemporaryFile() if this change is applied, instead of leaving it as an alias for NamedTemporaryFile(). I can't imagine not wanting the guaranteed cleanup semantics of O_TEMPORARY in the case of an anonymous temporary file that doesn't need to be reopened. I also want O_SHORT_LIVED. This opens the file with the attribute FILE_ATTRIBUTE_TEMPORARY [1], which tells the cache manager to try to keep the file contents in memory instead of flushing data to disk.
---
[1] https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew#caching_behavior |
|
Date |
User |
Action |
Args |
2021-04-12 21:52:05 | eryksun | set | recipients:
+ eryksun, paul.moore, jaraco, ncoghlan, pitrou, eric.smith, tim.golden, jwilk, eric.araujo, r.david.murray, njs, dabrahams, ethan.furman, davide.rizzo, sbt, Gabi.Davar, martin.panter, piotr.dobrogost, zach.ware, dlenski, steve.dower, Carl Osterwisch, ethan smith, John Florian, ev2geny, chary314 |
2021-04-12 21:52:05 | eryksun | set | messageid: <1618264325.37.0.568205039865.issue14243@roundup.psfhosted.org> |
2021-04-12 21:52:05 | eryksun | link | issue14243 messages |
2021-04-12 21:52:05 | eryksun | create | |
|