Arcturus B Arcturus B -4 years ago 112
Python Question

OSError 24 (Too many open files) when reading bunch of FITS with

I’m trying to load into memory a few 2 000 FITS using

def readfits(filename):
with as ft:
# the fits contain a single HDU
data = ft[0].data
return data

data_sci = []
for i in range(2000):

However, when reaching the 1015th file,
OSError: [Errno 24] Too many open
is raised.

I have the same issue with:

def readfits(filename):
ft = as ft:
data = ft[0].data
return data

I suspect that
does not properly close the file. Is there a
way I can force the files to be closed?

Answer Source
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download