![]() |
#1 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,178
Karma: 2431850
Join Date: Sep 2008
Device: IPad Mini 2 Retina
|
Help needed with send metadata to device callback
I am trying to understand what is going on in the logs posted here: https://www.mobileread.com/forums/sho...&postcount=102
Specifically, this pattern occurs whenever there is an "database disk image is malformed" error: Code:
Job: 5 Send metadata to device started DEBUG: 686.4 iOSReaderApp:sync_booklists() DeviceJob: 5 Send metadata to device done, calling callback database disk image is malformed Traceback (most recent call last): File "site-packages\calibre\gui2\device.py", line 87, in run File "site-packages\calibre\gui2\device.py", line 532, in _sync_booklists File "C:\Users\Andrew\AppData\Local\Temp\calibre_bpv2hl\fa0znv_ios_local_db\Marvin_overlays.py", line 1009, in sync_booklists File "C:\Users\Andrew\AppData\Local\Temp\calibre_bpv2hl\fa0znv_ios_local_db\Marvin_overlays.py", line 2109, in _profile_db DatabaseError: database disk image is malformed DeviceJob: 5 Send metadata to device callback returned
From the device.py code I have not been able to tell what callback is being called. If there are two threads here, it could explain why the error is occurring. Or am I reading this wrong? Thanks |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,415
Karma: 8012664
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Speaking from some knowledge of device drivers but no knowledge of the iOS plugins:
It appears that the iOS reader plugin is acting as a device driver. If so, then all methods in that plugin are called on the device manager thread, which is not the GUI thread. Every method in the plugin must complete its task during a single call. Unless you are very careful, it must not use sub-threads to do anything. The sync_booklists call is usually called as part of a set of job steps. 1) [Device thread] Connect to device 2) [Device thread] Initialize the device 3) [Device thread] Get booklists (metadata) from device 4) [GUI thread] match books from device to calibre library 5) [Device thread] Send metadata back to the device (sync_booklists) 6) [GUI thread] Update views The profile_db method will be called on the device thread. You can't trust the printout order because of threading. You must be absolutely sure that nothing in the user interface plugin (marvin XD) calls any method in the iOS reader applications plugin, because that could cause threading problems. I have no idea if this helps. ![]() |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,318
Karma: 27111242
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Look at devices/interface.py
Every single method in the Device object is called in the device thread, with a few exceptions, which are documented (search for thread in that file). The calibre user interface is in the GUI thread, device operations are in the device thread, so as not to block the UI. The vast majority of device driver code is all executed in the device thread and calibre automatically takes care of dispatching events to the UI thread as appropriate. The few exceptions are documented in interface.py |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Multiple books convert on send, Repeats Metadata Send | theducks | Library Management | 2 | 09-29-2012 11:55 AM |
Help needed: Send ebooks via email | rfog | Onyx Boox | 3 | 08-17-2012 03:27 AM |
Send to device based on Metadata | DavidTC | Calibre | 0 | 09-18-2011 01:18 PM |
"add metadata as 1st page" won't work on batch [send to device] | Bellychaser | Devices | 3 | 01-25-2011 03:25 PM |
Send to Device & Metadata | Bob Butler | Calibre | 18 | 02-22-2009 09:33 PM |