I have this simple function :
def get_schema_label(uri):
import surf
store = surf.Store(reader='rdflib',writer='rdflib',rdflib_store='IOMemory')
session = surf.Session(store)
store.load_triples(source=uri)
ontology = session.get_class(surf.ns.OWL.Ontology)
o = ontology(uri)
label = unicode(o.rdfs_label.first)
store.clear()
store.close()
#session.close()
return(label)
get_schema_label('
http://www.w3.org/ns/org#')
it works, but I uncomment session.close() I get this error
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/dom/django/base/d2rq/models.py", line 27, in save
self.label = get_schema_label(self.uri)
File "/Users/dom/django/base/d2rq/models.py", line 16, in get_schema_label
session.close()
File "/Users/dom/django/.virtualenvs/base/lib/python2.7/site-packages/SuRF-1.1.4_r352-py2.7.egg/surf/session.py", line 287, in close
for store in self.__stores:
RuntimeError: dictionary changed size during iteration
If I don't close my sessions I suppose this will have an impact on memory ?