There was a discussion and proposal about adding the equivalent of this
with psgix.cleanup callbacks a while ago (check github wiki of psgi-specs
repo) but so far as I know none of the servers has implemented it.
The easiest workaround would be to make a simple job queue (probably one of
the existing one off of CPAN) to launch them in the background.
Sent from my iPad
On Jul 3, 2012, at 2:09 PM, dstroma <dstr...@gmail.com> wrote:
I am converting some apps over from mod_perl and I'm trying to figure out
how to replace functionality previously performed in a PerlCleanupHandler.
It was useful for doing some work at the end of the request without
blocking the client.
> There is no *cleanup* Apache phase, it exists only inside mod_perl. It is
> used to execute some code immediately after the request has been served
> (the client went away) and before the request object is destroyed.
> There are several usages for this use phase. The obvious one is to run a
> cleanup code, for example removing temporarily created files. The less
> obvious is to use this phase instead of PerlLogHandler<http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlLogHandler>if the logging operation is time consuming. This approach allows to free
> the client as soon as the response is sent.
I tried using the "streaming body" feature of the PSGI spec, by calling
$writer->close and then doing the cleanup work, but that seems to be
blocking also; plus, is a bit of a complicated way of doing it when the
rest of the app doesn't really need streaming.
Any other solutions?