What Plack webservers currently support the PSGI environment cleanup handlers proposal?

124 views
Skip to first unread message

Ævar Arnfjörð Bjarmason

unread,
Sep 7, 2012, 10:37:31 AM9/7/12
to psgi-...@googlegroups.com, Hans Dieter Pearcey
Has anyone implemented the PSGI cleanup handler proposal: https://github.com/plack/psgi-specs/wiki/Proposal:-PSGI-environment-cleanup-handlers

If not then which servers support the Plack::Middleware::Cleanup hack (https://metacpan.org/module/Plack::Middleware::Cleanup)? I've tried with uWSGI and it always executes that cleanup handler within the main request.

Tatsuhiko Miyagawa

unread,
Sep 7, 2012, 11:38:05 AM9/7/12
to psgi-...@googlegroups.com

On Sep 7, 2012, at 7:37 AM, Ævar Arnfjörð Bjarmason wrote:

Has anyone implemented the PSGI cleanup handler proposal: https://github.com/plack/psgi-specs/wiki/Proposal:-PSGI-environment-cleanup-handlers



If not then which servers support the Plack::Middleware::Cleanup hack (https://metacpan.org/module/Plack::Middleware::Cleanup)? I've tried with uWSGI and it always executes that cleanup handler within the main request.

As the doc says it has some flaws, mainly that in most web servers the connection is not closed till the cleanup job is executed.

Roberto De Ioris

unread,
Sep 7, 2012, 11:40:01 AM9/7/12
to psgi-...@googlegroups.com
> --

But is it part of PSGI ? implementing it in uWSGI would be really easy (there is an hook for that case than can be simply extended).
--
Roberto De Ioris
http://unbit.it
JID: rob...@jabber.unbit.it

Tatsuhiko Miyagawa

unread,
Sep 7, 2012, 1:14:30 PM9/7/12
to psgi-...@googlegroups.com
It's not part of the PSGI core, it was proposed as an extension almost one year ago. There was a good discussion (linked from the wiki page) but nobody has bothered to implement it, yet.

--




Roberto De Ioris

unread,
Sep 7, 2012, 1:19:15 PM9/7/12
to psgi-...@googlegroups.com

Il giorno 07/set/2012, alle ore 19:14, Tatsuhiko Miyagawa <miya...@gmail.com> ha scritto:

> It's not part of the PSGI core, it was proposed as an extension almost one year ago. There was a good discussion (linked from the wiki page) but nobody has bothered to implement it, yet.
>
> https://github.com/plack/psgi-specs/wiki/Proposal:-PSGI-environment-cleanup-handlers
> https://github.com/plack/psgi-specs/issues/18
>
>

I have just implemented it in uWSGI, this is an example:

https://github.com/unbit/uwsgi/blob/master/test.psgi

while the relevant code is here:

https://github.com/unbit/uwsgi/blob/master/plugins/psgi/psgi_plugin.c#L494

Tatsuhiko Miyagawa

unread,
Sep 7, 2012, 1:23:10 PM9/7/12
to psgi-...@googlegroups.com
Ha, nice!

push $env->{'psgix.cleanup.handlers'}, $one;

Guess this syntax is perl 5.14+ only :)

--
Tatsuhiko Miyagawa



--




Roberto De Ioris

unread,
Sep 7, 2012, 1:36:59 PM9/7/12
to psgi-...@googlegroups.com

Il giorno 07/set/2012, alle ore 19:23, Tatsuhiko Miyagawa <miya...@gmail.com> ha scritto:

> Ha, nice!
>
> > push $env->{'psgix.cleanup.handlers'}, $one;
>
> Guess this syntax is perl 5.14+ only :)

oops :P fixed

Ævar Arnfjörð Bjarmason

unread,
Sep 7, 2012, 2:53:04 PM9/7/12
to psgi-...@googlegroups.com

This is fantastic, I'm going to be hacking something up with it.

--



Ævar Arnfjörð Bjarmason

unread,
Oct 1, 2012, 6:22:29 PM10/1/12
to psgi-...@googlegroups.com, Roberto De Ioris
As a brief update on this, the servers that currently support the
cleanup proposal are:

* uWSGI in the 1.3 release

* Plack::Handler::Apache2 which I submitted a patch for, merged into
Plack but not in a CPAN release yet.

* I submitted a pull request for Starman adding support for it:
https://github.com/miyagawa/Starman/pull/53

I also suggested some minor changes to the cleanup spec, specifically
https://github.com/plack/psgi-specs/pull/26/files. It would be
compatible with all the existing servers above, but they could be
further patched to provide the following variables/values:

psgix.cleanup.can_commit_harakiri = 1
psgix.cleanup.runs_on_committed_harakiri = 1

To indicate what their cleanup phases are capable of.
Reply all
Reply to author
Forward
0 new messages