[Koha-devel] Background jobs in plugins

David Cook dcook at prosentient.com.au
Mon Oct 16 07:16:03 CEST 2023


I thought about that although it’s worth restarting in any case, so the cache issue is probably not all that important. 

 

David Cook

Senior Software Engineer

Prosentient Systems

Suite 7.03

6a Glen St

Milsons Point NSW 2061

Australia

 

Office: 02 9212 0899

Online: 02 8005 0595

 

From: Tomas Cohen Arazi <tomascohen at gmail.com> 
Sent: Monday, October 16, 2023 4:13 PM
To: David Cook <dcook at prosentient.com.au>
Cc: Kyle Hall <kyle.m.hall at gmail.com>; Koha Devel <koha-devel at lists.koha-community.org>; Kyle Hall <kyle at bywatersolutions.com>
Subject: Re: [Koha-devel] Background jobs in plugins

 

Please file bug reports on your findings or ideas so they don't fall into void.

 

El lun, 16 oct 2023 1:42, David Cook <dcook at prosentient.com.au <mailto:dcook at prosentient.com.au> > escribió:

Thanks for doing that, Tomas. That was really helpful. 

 

Even with your email and the Github example, it still wasn’t working for me…until I realized that I should restart the background job workers.

 

In hindsight, it’s obvious that the Koha/BackgroundJob.pm would only load the plugin 1 time. It also appears that the product of “plugin_types_to_classes” is also cached too long. My background workers would’ve cached the bad code and bad mapping early in my testing. 

 

The mapping cache doesn’t have an invalidation mechanism, so if you already have 1 plugin with a background task, I don’t think it’ll allow a 2nd plugin to appear in the mapping if a task from the 1st plugin is processed before the 2nd plugin is loaded. I haven’t thoroughly investigated that though…

 

Overall, probably best to require a restart of the background workers as well as Plack any time a plugin is added which contains a background job. 

 

David Cook

Senior Software Engineer

Prosentient Systems

Suite 7.03

6a Glen St

Milsons Point NSW 2061

Australia

 

Office: 02 9212 0899

Online: 02 8005 0595

 

From: Kyle Hall <kyle.m.hall at gmail.com <mailto:kyle.m.hall at gmail.com> > 
Sent: Saturday, October 14, 2023 2:48 AM
To: Tomas Cohen Arazi <tomascohen at gmail.com <mailto:tomascohen at gmail.com> >
Cc: David Cook <dcook at prosentient.com.au <mailto:dcook at prosentient.com.au> >; Koha Devel <koha-devel at lists.koha-community.org <mailto:koha-devel at lists.koha-community.org> >; Kyle Hall <kyle at bywatersolutions.com <mailto:kyle at bywatersolutions.com> >
Subject: Re: [Koha-devel] Background jobs in plugins

 

I love it Tomas!

 

---

http://www.kylehall.info
ByWater Solutions ( http://bywatersolutions.com )
Meadville Public Library ( http://www.meadvillelibrary.org )
Crawford County Federated Library System ( http://www.ccfls.org )

 

 

On Fri, Oct 13, 2023 at 9:51 AM Tomas Cohen Arazi <tomascohen at gmail.com <mailto:tomascohen at gmail.com> > wrote:

Look at this commit:

 

https://github.com/bywatersolutions/dev-koha-plugin-kitchen-sink/commit/30d1446387fa864fe49f25cb53a2915b33ef73ce

 

Best regards

 

El vie, 13 oct 2023 a las 10:09, Tomas Cohen Arazi (<tomascohen at gmail.com <mailto:tomascohen at gmail.com> >) escribió:

Hi all. I'm wrapping a KitchenSink patch to highlight how it would be used.

 

The background jobs themselves work, but the template side I never looked at. I thought there was some default display showing all the report metadata, but it seems all descriptions are hardcoded and a dev is required to add the ability for plugins to advertise job descriptions and have them displayed as well.

 



 

If you want a plugin background job, it works and you should look at the wiki (updated just now) and/or copy what I've done on the KitchenSink plugin.

 

Regarding comments on IRC, the feature was submitted during the 2022's hackfest in an attempt to streamline the whole background jobs work by Jonathan, and was tested, QA and pushed by others. We succeeded in moving that forward, which Fridolin pushed for 22.05 and was a great improvement.

 

Best regards

 

El vie, 13 oct 2023 a las 3:25, David Cook (<dcook at prosentient.com.au <mailto:dcook at prosentient.com.au> >) escribió:

Hi all,

 

“Bug 30410 - Add a way for plugins to register background tasks” was pushed in Koha 22.05.00, but I can’t figure out how to make it work.

 

Tomas, do you have a plugin where this works?

 

I’ve gone through the patches, and it looks like I should have it right, but nothing I’m doing is working.

 

When I enqueue the job, background_jobs.pl <http://background_jobs.pl>  says “Unknown job type 'plugin_blah_blah'” even though “plugin_blah_blah” exists in Koha::BackgroundJob->new->type_class_mapping and in my plugin background job’s “job_type”. 

 

When I click “View” on the job, I get the following error: “Template process failed: file error - background_jobs/plugin_blah_blah.inc: not found at /kohadevbox/koha/C4/Templates.pm line 127”

 

I’ll look next week at providing a simple plugin to illustrate the problem…

 

Thanks,

 

David Cook

Senior Software Engineer

Prosentient Systems

Suite 7.03

6a Glen St

Milsons Point NSW 2061

Australia

 

Office: 02 9212 0899

Online: 02 8005 0595

 




 

-- 

Tomás Cohen Arazi

Theke Solutions (https://theke.io)
✆ +54 9351 3513384
GPG: B2F3C15F




 

-- 

Tomás Cohen Arazi

Theke Solutions (https://theke.io)
✆ +54 9351 3513384
GPG: B2F3C15F

_______________________________________________
Koha-devel mailing list
Koha-devel at lists.koha-community.org <mailto:Koha-devel at lists.koha-community.org> 
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20231016/71a87828/attachment.htm>


More information about the Koha-devel mailing list