06-13-2011, 06:09 PM | #76 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Hmm perhaps one way is to allow passing of a previous job parameter to the DeviceJob class. Then the function that launches a job chain should schedule all n jobs at once so that they are atomic. The nth job should check if the n-1th job finished successfully, if so, it should run, if not it should abort.
Sounds reasonable? |
06-14-2011, 04:10 AM | #77 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Yes, but I think the complexity of knowing the entire chain in advance would lead to bugs. In addition, it doesn't deal well with job forks (alternate jobs later in the chain), although I don't think we currently have any of those.
Something that would work and be easier to live with (I think) would be to add a second queue to the job manager, a 'job chain' queue, and another parameter to create_job indicating that this job is part of a chain. The job dispatcher would take jobs from that queue until empty, then take jobs from the normal queue. FD semantics ensure that the next job is queued before the first job terminates. Thus, if one uses FD around done and sets the job_chain parameter, then the chain will be atomic. |
Advert | |
|
06-14-2011, 11:18 AM | #78 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Works for me, though what happens if there need to be two sets of atomic jobs? How would a later job in the chain know which chain to pass to create job?
|
06-14-2011, 02:34 PM | #79 |
Sigil developer
Posts: 1,275
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
|
As a note on my plugin - I don't actually create any other jobs in my plugin once my create_job starts. I used to accidentally call the get_device information job (to get device uuid) but realized that this messed up my percentage done indicator, and I could just get the values directly from calibre since get_devices had already run.
Out of curiousity, I'm currently calling the get_device_information immediately after my create job, but should I be calling it in my completed job function - since I don't need it to run until after my job completes anyway? I couldn't get this to work at first and so just moved it up to the main function where it worked and I left it. (I just use the completed function to present a dialog to the user to show them the report and nothing depends on them closing the dialog). |
06-14-2011, 02:49 PM | #80 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
The currently running job wins. The second job won't get started until the first job either finishes the chain, schedules a subsequent job in a Dispatcher, or schedules a subsequent job without the chain flag set.
|
Advert | |
|
06-14-2011, 02:52 PM | #81 | |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
|
|
06-14-2011, 02:54 PM | #82 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
OK by me, I have higher priority stuff to work on at the moment, so I'll leave this alone. When you return, will you implement it, since it is your idea?
|
06-14-2011, 02:59 PM | #83 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
OK. Won't be for this week's release though.
|
06-14-2011, 03:05 PM | #84 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
|
06-19-2011, 09:46 AM | #85 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
The create job subsequence changes are in source.
These changes ensure that under certain conditions, follow-on jobs scheduled by a running job run before jobs scheduled in other ways. For example, two-step jobs like upload_books will run both steps before another job can be run. The conditions are: - The sub-job must be created while the creating job is running. In practice, this means that the sub-job must be created in the done function of the creating job. - The done function of the sub-job must be encapsulated with FunctionDispatcher(). All the standard jobs in device.py respect these conditions. If anyone has uses job sequences and wants to use this feature, call create_job_step passing in the job value. This is the first parameter passed to a done function. See books_uploaded, the done function for upload_books, for an example of scheduling upload_booklists as a sub-job. @meme: could you try two things? 1) See if it still works with the code you have, and whether the job sequencing changes (according to the log). 2) Switch back to device_manager.books and check if it still works. My strong suspicion is that both 1 and 2 will work. You can change it back to get_device_info for your production version. |
06-19-2011, 10:10 AM | #86 |
Sigil developer
Posts: 1,275
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
|
I'll give it a test tomorrow.
|
06-20-2011, 02:23 PM | #87 |
Sigil developer
Posts: 1,275
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
|
I'm not sure of the results at this point - will need more time to test. On the surface the collections seem to be getting created ok in the current release and the new source, but the job output seems mixed.
It might help if the Job printed a 'job started' as well as a 'job finished' line in the debug output (I can add one for me, but it might be helpful in general. This output is from starting calibre with device collected and already having some new books in the Reading List ready to sync. 0.8.6: Code:
Job: 1 Get device information finished Job: 2 Get list of books on device finished Job:[output messed up, interleaved with other text] Job: 5 Get device information finished Job: 4 Create Kindle Collections finished Job: 6 Send metadata to device finished Job: 7 Get list of books on device finished Dowloaded Source: Code:
Job: 1 Get device information finished Job: 2 Get list of books on device finished Job: 3 Upload 5 books to device:Life, the Universe and Everything, So Long, and Thanks For All the Fish, Mostly Harmless, The Hitchhiker’s_Guide_to the Galaxy, The_Restaurant_at the End of the Universe finished Job: 6 Send metadata to device finished Job: 6 Send metadata to device finished Job: 4 Create Kindle Collections finished Job: 5 Get device information finished Job: 7 Get list of books on device finished |
06-20-2011, 02:40 PM | #88 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I committed code to print out job started notifications.
|
06-20-2011, 03:27 PM | #89 |
Sigil developer
Posts: 1,275
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
|
Thanks.
First test Code:
Job: 1 Get device information started Job: 2 Get list of books on device started Job: 1 Get device information finished Job: 3 Upload 5 books to device:Life, the Universe and Everything, So Long, and Thanks For All the Fish, Mostly Harmless, The Hitchhiker’s_Guide_to the Galaxy, The_Restaurant_at the End of the Universe started Job: 2 Get list of books on device finished Job: 6 Send metadata to device started Job: 3 Upload 5 books to device:Life, the Universe and Everything, So Long, and Thanks For All the Fish, Mostly Harmless, The Hitchhiker’s_Guide_to the Galaxy, The_Restaurant_at the End of the Universe finished Job: 4 Create Kindle Collections started Job: 6 Send metadata to device finished Job: 5 Get device information started Job: 7 Get list of books on device started Job: 4 Create Kindle Collections finished Job: 5 Get device information finished Job: 7 Get list of books on device finished It seems odd to see the get list of books (job 2) finish before Reading List (job 3) starts uploading books. I would think it would need to wait until the list is fully gotten in order to know what's on the device. I'll see if I can figure out how to revert my copy of the source to 0.8.6 and then add in the job started print that you had to see if there's really any difference. Since I didn't study the original output, just the effect, I can't tell if what I'm seeing is an issue or has always been that way. |
06-20-2011, 03:40 PM | #90 |
creator of calibre
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
started means that it has actually started. The Finished print out may not be very accurate however, as it is run in another thread. I've committed code to print out exactly when it finishes and the callback is called.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
eBooks from the library —waiting waiting | Khendron | Kobo Reader | 9 | 05-12-2010 01:02 PM |
Which one of these activities do you dedicate more time to? | daviddem | Lounge | 24 | 12-26-2008 11:40 AM |
iRex to expand B2B activities / speaks of possible IPO | Alexander Turcic | iRex | 12 | 04-10-2007 09:36 AM |