我怎样才能成为来自Apache 2缓冲CGI内容? [英] How can I serve unbuffered CGI content from Apache 2?

查看:228
本文介绍了我怎样才能成为来自Apache 2缓冲CGI内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想是能够允许用户查看一个长期运行GCI脚本的输出,因为它是生成而不是之后脚本完成。但是,即使当我明确地冲洗STDOUT服务器似乎等待脚本发送到客户端的响应之前完成。这是运行Apache 2.2.9在Linux服务器上。

I would like to be able to allow a user to view the output of a long-running GCI script as it is generated rather than after the script is complete. However even when I explicitly flush STDOUT the server seems to wait for the script to complete before sending the response to the client. This is on a Linux server running Apache 2.2.9.

例如CGI巨蟒:

#!/usr/bin/python

import time
import sys


print "Content-type: text/plain"
print
for i in range(1, 10):
        print i
        sys.stdout.flush()
        time.sleep(1)

print "Done."

在Perl中类似的例子:

Similar example in perl:

#!/usr/bin/perl

print "Content-type: text/plain\n\n";

for ($i = 1; $i <= 10 ; $i++) {
        print "$i\n";
        sleep(1);
}

print "Done.";

这个链接说像Apache 1.3 CGI输出应该是无缓冲(但这可能仅适用于Apache的1.x中):<一href=\"http://httpd.apache.org/docs/1.3/misc/FAQ-F.html#nph-scripts\">http://httpd.apache.org/docs/1.3/misc/FAQ-F.html#nph-scripts

This link says as of Apache 1.3 CGI output should be unbuffered (but this might apply only to Apache 1.x): http://httpd.apache.org/docs/1.3/misc/FAQ-F.html#nph-scripts

任何想法?

推荐答案

兰德尔·施瓦茨的文章观看通过CGI 解释了不同的长流程(恕我直言,更好的)看长期运行的进程的方法。

Randal Schwartz's article Watching long processes through CGI explains a different (and IMHO, better) way of watching a long running process.

这篇关于我怎样才能成为来自Apache 2缓冲CGI内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆