I have a class that reads data from a number of HDF5 files, and to save
time opening them, I'm trying to use a WeakValueDictionary as a simple
cache. But File objects seem to have more references than just the
label returned from openFile.
In [1]: import weakref
In [2]: import tables
In [3]: cache = weakref.WeakValueDictionary()
In [4]: fyle = tables.openFile('Foo-1990.h5')
In [5]: import sys
In [6]: sys.getrefcount(fyle)
Out[6]: 6
In [9]: cache[0] = fyle
In [10]: sys.getrefcount(fyle)
Out[10]: 6
In [11]: del fyle
In [12]: cache.keys()
Out[12]: [0]
In [13]: sys.getrefcount(cache.values()[0])
Out[13]: 5
(In this example 'Foo-1990.h5' has roughly 250 Arrays, all off the root
group, but I've opened up files with only three arrays and gotten even
higher refcounts.)
I've checked to see whether PyTables is caching the file instances, but
repeated calls to tables.openFile return different objects.
What is holding these references? What is the proper way to completely
remove a File object?
--
Anthony Foglia
Princeton Consultants
(609) 987-8787 x233
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Pytables-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pytables-users