[Import-SIG] Loading Resources From a Python Module/Package

PJ Eby pje at telecommunity.com
Sat Jan 31 19:05:10 CET 2015


On Sat, Jan 31, 2015 at 12:44 PM, Barry Warsaw <barry at python.org> wrote:
> On Jan 30, 2015, at 07:52 PM, Donald Stufft wrote:
>
>>> On Jan 30, 2015, at 7:18 PM, Paul Moore <p.f.moore at gmail.com> 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.)


More information about the Import-SIG mailing list