[Nepomuk] AsyncQuery in Python

Sebastian Trüg trueg at kde.org
Tue May 11 16:04:55 CEST 2010


Hi Stephane,

On 05/11/2010 10:54 AM, Stéphane Laurière wrote:
> I'm trying to execute an AsyncQuery using the Python bindings with the
> snippet below taken from [1] but I get the following error: "Soprano"
> Error in thread "Invalid iterator ID.", and the query slot is never
> called. Any idea why? The same query executed in sync mode works fine.

>      def query(self):
>      	query = Soprano.Util.AsyncQuery.executeQuery(model, self.sparql, 

you forgot the "self." query is probably garbage collected after this
method. Not sure, this is a guess...

> Soprano.Query.QueryLanguageSparql)
>      	QObject.connect( query, SIGNAL("nextReady(Soprano.Util.AsyncQuery* 
> ) "), self.queryNextReadySlot)

you know that you can use the fancy way:

self.query.nextReady.connect(self.queryNextReadySlot)

:)

> if __name__ == "__main__":
> 	
> 	nepomukType = Nepomuk.Types.Class(Soprano.Vocabulary.RDFS.Resource())
> 	term = Nepomuk.Query.ResourceTypeTerm(nepomukType)
> 	query = Nepomuk.Query.Query(term)
> 	sparql = query.toSparqlQuery()
> 	asyncmodel = AsyncResourceLoadingModel(sparql)
> 	asyncmodel.query()

Also you never enter any event loop. So the app will quit before any
slot is executed.

Cheers,
Sebastian


More information about the Nepomuk mailing list