[Nepomuk] AsyncQuery in Python

Stéphane Laurière slauriere at mandriva.com
Wed May 12 11:47:31 CEST 2010


Indeed, I had overlooked the need of an event loop... The query's
working fine. Thanks.

Cheers
Stéphane



> 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
> _______________________________________________
> Nepomuk mailing list
> Nepomuk at kde.org
> https://mail.kde.org/mailman/listinfo/nepomuk
>
>


-- 
Stéphane Laurière
Mandriva http://mandriva.com



More information about the Nepomuk mailing list