J
John Marshall
Hi,
Does anyone see a problem with doing:
data = file("tata").read()
Each time this is done, I see a new file
descriptor allocated (Linux) but not
released.
1) Will there ever be a point where I
will have a problem with file
descriptors because the garbage
collector has _not_ yet collected the
file objects?
2) When I subclassed the file object as
follows:
-----
class MyFile(file):
def close(self):
print "MyFile.close()"
file.close(self)
-----
and did a simple 'MyFile("tata")' I did not see
a call to MyFile.close(). Am I wrong to have
expected MyFile.close() to have been called?
3) There is no file.__del__() as far as I
can tell at the Python level. Are files
opened by the calls above properly
closed when the objects are destroyed
and collected?
Thanks,
John
Does anyone see a problem with doing:
data = file("tata").read()
Each time this is done, I see a new file
descriptor allocated (Linux) but not
released.
1) Will there ever be a point where I
will have a problem with file
descriptors because the garbage
collector has _not_ yet collected the
file objects?
2) When I subclassed the file object as
follows:
-----
class MyFile(file):
def close(self):
print "MyFile.close()"
file.close(self)
-----
and did a simple 'MyFile("tata")' I did not see
a call to MyFile.close(). Am I wrong to have
expected MyFile.close() to have been called?
3) There is no file.__del__() as far as I
can tell at the Python level. Are files
opened by the calls above properly
closed when the objects are destroyed
and collected?
Thanks,
John