PerlCleanupHandler substitute

56 views
Skip to first unread message

dstroma

unread,
Jul 3, 2012, 4:09:59 PM7/3/12
to psgi-...@googlegroups.com
Hi,

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.

PerlCleanupHandler

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 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?

Thanks


Tatsuhiko Miyagawa

unread,
Jul 4, 2012, 2:21:13 AM7/4/12
to psgi-...@googlegroups.com
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
Reply all
Reply to author
Forward
0 new messages