in reply to How to enqueue again from the job in POE::Component::JobQueue?

First, you should use POE::Kernel's sig_child() method to register a SIGCHLD handler for POE::Wheel::Run children. This will ensure your child processes get reaped, otherwise your machine will clog up with them.

sub worker_start { my ($kernel,$session,$heap,@args) = @_[KERNEL, SESSION, HEAP, ARG0 .. + $#_]; $heap->{postback} =$args[0]; $heap->{filename} =$args[1]; $heap->{cmdline} = POE::Wheel::Run::Win32->new(...); $kernel->sig_child($heap->{cmdline}->PID, "sig_child"); }

The problem with reposting the job request from a worker is that the worker becomes the requester. It will be kept alive until the reposted job is done, and it will receive the results of that job. Not what you want.

As I see it, you have two options. First, you could return a "busy, try again" sort of response in this case. The requesting session would then need to repost the request itself. This is perhaps the cleanest generic design, since the application should have final say over policy.

Your second option is to contact the author and ask for a "retry" feature where a worker can reënqueue a job when necessary. If you can provide a patch and testcase, that would even be better. See http://rt.cpan.org/ for contact instructions.

  • Comment on Re: How to enqueue again from the job in POE::Component::JobQueue?
  • Download Code

Replies are listed 'Best First'.
Re^2: How to enqueue again from the job in POE::Component::JobQueue?
by wl2776 (Novice) on Mar 05, 2009 at 14:22 UTC
    > First, you could return a "busy, try again" sort of response in this case.
    > The requesting session would then need to repost the request itself.

    Ok, this is the option.

    I am new to POE. Could you be more specific? How and where should I get this reply?

      The reply should be sent back to the session that post()'ed the request. The reply will be returned via a "postback" event, which the worker will "post back" to you. The purpose of the third parameter in the request post() is to tell POE::Component::JobQueue which of the requesting session's handlers will accept the response.