[Kde-pim] Problem with bulk fetching of items with 4.8
Shaheed Haque
srhaque at theiet.org
Sun Jan 29 19:18:44 GMT 2012
Thanks for all the tips.
I've recoded things to use individual ItemCreateJobs, and including
trying QMetaObject::invokeMethod() in place of scheduleCustomTask(),
so while I think the structure is closer to what is being advised, I
think I am missing something in terms of the exact behaviour of the
jobs because I always get stuck at the end of the first batch, trying
to update the collection attributes.
The design is now a nicely linear flow like this:
void ExGalResource::retrieveItems(const Akonadi::Collection &collection)
{
//scheduleCustomTask(this, "retrieveGALBatch", QVariant(),
ResourceBase::Append);
QMetaObject::invokeMethod(this, "retrieveGALBatch", Qt::QueuedConnection);
cancelTask();
}
//void ExGalResource::retrieveGALBatch(const QVariant &)
void ExGalResource::retrieveGALBatch()
{
...
taskDone();
createGALItem();
}
void ExGalResource::createGALItem()
{
...
Akonadi::ItemCreateJob *job = new Akonadi::ItemCreateJob(item, m_gal,
transaction());
connect(job, SIGNAL(result(KJob *)), SLOT(createGALItemDone(KJob *)));
}
void ExGalResource::createGALItemDone(KJob *job)
{
if (more items to create) {
createGALItem();
} else {
updateGALStatus(realJob->item().payload<KABC::Addressee>().name());
}
}
void ExGalResource::updateGALStatus(QString lastAddressee)
{
taskDone();
Akonadi::CollectionAttributesSynchronizationJob *job = new
Akonadi::CollectionAttributesSynchronizationJob(m_gal);
connect(job, SIGNAL(result(KJob *)), SLOT(updateGALStatusDone(KJob *)));
job->start();
}
void ExGalResource::updateGALStatusDone(KJob *job)
{
if (job->error()) {
qCritical() << "updateGALStatusDone:" << job->errorString();
}
taskDone();
//scheduleCustomTask(this, "retrieveGALBatch", QVariant(),
ResourceBase::Append);
QMetaObject::invokeMethod(this, "retrieveGALBatch", Qt::QueuedConnection);
}
The problem is that this last slot updateGALStatusDone() is only
invoked quite a few MINUTES after I expect, and with this output:
...
createGALItem: 738
createGALItemDone: 765
createGALItemDone: 757
createGALItem: 738
createGALItemDone: 765
createGALItemDone: 757
createGALItem: 738
createGALItemDone: 765
createGALItemDone: 762
updateGALStatus 780
updateGALStatus 795
updateGALStatus 798
createGALItemDone: 765
updateGALStatusDone: "Collection attributes synchronization timed out."
updateGALStatusDone: 812
updateGALStatusDone: 816
retrieveGALBatch: 688
Now, sometime, I also see this:
Error during executing query "UPDATE PimItemTable SET atime = :0 WHERE
( collectionId = :1 )" : "Lock wait timeout exceeded; try restarting
transaction QMYSQL3: Unable to execute statement"
Unable to update item access time
So, it looks to me as though my understanding of the rules for these
async jobs is still incomplete, but I've not managed to track down
where that is - possibly to do with the ItemCreateJob handling?
Thanks, Shaheed
On 27 January 2012 20:47, Andras Mantia <amantia at kde.org> wrote:
> Kevin Krammer wrote:
>
>> However, since the purpose of custom task right here seems to be calling
>> retrieveGALItems() asynchronously you could do that with
>> QMetaObject::invokeMethod().
>
> AKA poor man's "threading". ;) Yeah, I also use this technique.
>
> Andras
> _______________________________________________
> KDE PIM mailing list kde-pim at kde.org
> https://mail.kde.org/mailman/listinfo/kde-pim
> KDE PIM home page at http://pim.kde.org/
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/
More information about the kde-pim
mailing list