karzilla: a green fist above the word SMASH! (Default)
[staff profile] karzilla

Bug counts: resolved 229, assigned 23, needs-review 19



Continuing on the subject of things that weren't as hard as I feared: making a gearman worker.

Here's your basic gearman worker in its entirety:
use LJ::Worker::Gearman;
gearman_decl( 'name-of-worker'  => \&worker );
gearman_work();
sub worker {
    # stuff what needs doing
}

And then you call it with something like LJ::gearman_client()->dispatch_background( 'name-of-worker', ...) (at least for my purposes, which were "go do this other time-consuming thing somewhere else and don't tell me what happens.")

The only real voodoo, AFAICT, is that you have to use Storable methods (freeze/thaw) for passing the function arguments from the web execution to the worker execution. I just did a copy and paste of code from someone else's worker script and it worked like a charm.

Later on I get to either write more gearman workers or overcome my fear of TheSchwartz, depending on whether or not gearman can do everything I need for delivering vgifts.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

Page generated Feb. 16th, 2026 04:37 am
Powered by Dreamwidth Studios