Re: Loading Resources From a Python Module/Package
PJ Eby <[email protected]> Sat, 31 Jan 2015 13:05:10 -0500
| Newsgroups | gmane.comp.python.import |
|---|---|
| Message-ID | <CALeMXf7M8D8=5Nh+3uJ2-V84+wHXsmKsxcDfTC3UxJ6W5f1PKw@mail.gmail.com> |
On Sat, Jan 31, 2015 at 12:44 PM, Barry Warsaw <[email protected]> wrote: > On Jan 30, 2015, at 07:52 PM, Donald Stufft wrote: > >>> On Jan 30, 2015, at 7:18 PM, Paul Moore <[email protected]> wrote: >>> Related question - how would the temp files be cleaned up? At exit? >> >>My patch registers an atexit handler that cleans up the temporary files yea. > > Why not implement it as a context manager? Note that neither approach will work for one common use of extracted files: extension modules and shared libraries on Windows. Unlike *nixy operating systems, you can't delete an open file on Windows, and loaded .DLLs are open files IIUC. Unless you've got some way to unload the .pyd or .dll files, you won't be able to do a complete cleanup in that case. (This use case is actually why I took the caching approach rather than the tempfile approach in the first place.)