View Single Post
Old 10-18-2019, 09:16 AM   #1
thiago.eec
Wizard
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 1,217
Karma: 1419583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
QObject::setParent: Cannot set parent, new parent is in a different thread

Hi, everyone.

I've created this plugin to sync calibre library and Skoob (a book social network, similar to GoodReads).

Skoob does not have a public API, so I had to scrape the website for data. The plugin logs in to Skoob and get the user data (progress, review, etc).

For better performance when fetching data, I used two strategies:

1) Keep a cookie, with an open session. This way, only the first 'click' will trigger the login. After that, if any function is used while calibre is still open, it will use the stored cookie and we gain a couple of seconds. OBS.: I could not find a way to make the cookie work after restarting calibre.

2) When selecting multiple books, each one is processed on a different thread. This really speeds up the task, since every book is processed in parallel. Although, here also lies the problem...

When the user selects a couple of books, calibre shows this error/warning on the debug log:
Code:
QObject::setParent: Cannot set parent, new parent is in a different thread
This message does not prevent the plugin to work. If the user selects up to around 20/25 books, calibre will show this message twice. If more books are selected, then it starts showing it more and more. With bigger selections, like 50 books, the message is shown 10/20 times. Sometimes, despite all the messages, the plugin still completes his job. But many times, calibre crashes.

I've tried to pinpoint what may be the cause for this, but I could not find it. So, I got around it using time delays. Initially, I had set a time.sleep(0.1) between each thread. Now, I've added a time.sleep(2) between every 20 books. This seems to avoid calibre crashing, but all the messages are still there.

Any hints?
Attached Files
File Type: zip Skoob_Sync.zip (173.0 KB, 317 views)
thiago.eec is offline   Reply With Quote