[AstroPy] Temporary files leaked by long-running process that calls astropy.utils.data.download_file

Singer, Leo P. (GSFC-661.0)[OAK RIDGE ASSOCIATED UNIVERSITIES (ORAU)] leo.p.singer at nasa.gov
Mon Sep 28 22:17:00 EDT 2015


Hi,

I have a process that is meant to run for a few days to months at a time, that is leaking temporary files whenever I download files using the functions in astropy.utils.data. I found no leaks in my own code. Then I looked in astropy.utils.data.get_readable_fileobj, and I found that the temporary files that it creates always make their way into the delete_fds list, and could not be leaked. Then I finally thought to look in astropy.utils.data.download_file itself, and found that it is leaking the files—at least until the interpreter exits cleanly!

            if conf.delete_temporary_downloads_at_exit:
                global _tempfilestodel
                _tempfilestodel.append(local_path)

I find the astropy.utils.data module very convenient, and I would like to continue to use it in this long-running process. Would the maintainers be open to a patch that adds an option to delete these temporary files immediately, instead of at cleanup?

Thanks,
Leo P. Singer
NASA Postdoctoral Program Fellow
Goddard Space Flight Center
8800 Greenbelt Rd., B34, Room S239
Greenbelt, MD 20771


More information about the AstroPy mailing list