On 10/26/06, Fayland Lam <[EMAIL PROTECTED]> wrote:
Matt S Trout wrote: > Fayland Lam wrote: >> Lee Standen wrote: >>> It's a subroutine, right? >>> >>> Tried a return?....such as: >>> >>> $c->res->redirect('http://www.yahoo.com'); >>> return undef; >> >> Indeed I want to run the 'while' loop in backend. 'return' would not >> run the loop I think. > > $c->res->redirect(...); > $c->finalize_headers; > > <while loop or whatever here> > > might do the trick >no, it doesn't work. maybe there is something concerned with 'butter', it's not sent immediately. and I use mod_perl2, so I'd like to have a try of system. Thanks any way.
It works if you manage to run your stuff after Catalyst calls
$c->finalize() in handle_request(). Funny, I just wrote a hack, err,
plugin yesterday which gives me the option to set up a hook that's
called right after $c->finalize(). I'm not sure if this is the correct
way to do it or if there are any side-effects, if any of the more
experient Catalyst users/developers think its a good idea for a
plugin, let me know and I'll can carve it up and release it.
I use mod_perl and haven't had any trouble so far, this approach lets
me delegate all the pre-fork management to apache. I have a Catalyst
front-end which adds jobs to a queue like mentioned before in the
thread and a another Catalyst server running XMLRPC that gets notified
about incoming jobs and runs them after responding to the XMLRPC
notification.
In MyApp.pm:
use Catalyst qw/AfterFinalize/;
In a controller action somewhere:
sub myaction : Local {
$c->res->body('running job');
$c->after_finalize(sub { run_job() } );
}
--
Eden Cardim
Instituto Baiano de Biotecnologia
Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas
Laboratório de Bioinformática
--
"you seem to think that 'close enough' is close enough...
please learn to be 'literal' around programming."
merlyn - on irc.freenode.net#perl
AfterFinalize.pm
Description: Perl program
_______________________________________________ List: [email protected] Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
