[Catalyst] $c->write() buffering?

Hailin Hu i at h2l.name
Thu Oct 31 03:03:43 GMT 2013


It is an engine relevant stuff.
Find which engine you are using ( for example, Plack::Handler::FCGI )
and look around codes around write(r), you may find something.
Good luck :)

On Wed, Oct 30, 2013 at 9:51 AM, Daniel J. Luke <dluke at geeklair.net> wrote:
> I've got some legacy CGI code that does a bunch of processing and uses the old hack of $| = 1; print "foo\n"; do_work(); print "foo done\n"; etc. (solution #1 from http://wiki.catalystframework.org/wiki/longcomputations)
>
> While I'll eventually convert it to a job queue, I'd like to create an output-identical implementation first with Catalyst, however it seems like I'm getting output buffering when I don't want it.
>
> As a very simple test, I've set up apache 2.2, mod_fastcgi (FastCgiExternalServer with -flush and without -flush) and a method like this:
>
> sub test: Local {
>     my ($self, $c) = @_;
>
>     $c->res->body('');
>     $c->response->content_type( 'text/plain; charset=utf-8' );
>     $c->finalize_headers;
>
>     my $i;
>     for($i=1;$i<8;$i++) {
>         $c->write("$i: foo bar baz\n");
>         sleep(1);
>     }
> }
>
> I see all the data at once in my browser instead of a line every second, and with tcpdump, can see that all of the data is coming back in one packet and not in 8+ smaller packets like I expect. If I make the string that gets passed to write longer, I get several packets, but all at once (and not with each iteration through the for loop).
>
> Am I missing something obvious? Is there some way to get the behavior I'm expecting?
>
> --
> Daniel J. Luke
> +========================================================+
> | *---------------- dluke at geeklair.net ----------------* |
> | *-------------- http://www.geeklair.net -------------* |
> +========================================================+
> |   Opinions expressed are mine and do not necessarily   |
> |          reflect the opinions of my employer.          |
> +========================================================+
>
>
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/



More information about the Catalyst mailing list