【发布时间】:2017-10-01 08:01:51
【问题描述】:
我使用 Perl Dancer2 作为带有基本设置的 RESTful 服务框架(使用命令
dancer2 -a MyWeb::App
生成模板文件并在自动生成的 MyWeb-App/lib/MyWeb/App.pm 文件中添加“get”路由)。最近我发现当一个请求需要很长时间才能完成时,服务器被锁定为只处理该请求。例如
get '/' => sub {# simple request to redirect to a static page
template 'index'; #template directive Templates all go into the views/
};
get '/compute' => sub{
for (my $i=0;$i<1000000;$i++){
wait(1000); #simulate long computation time
}
return "Done!";
};
当第一次在一个选项卡中输入 http://myhost.com/compute 时,在另一个选项卡中链接 http://myhost.com/ 将不会显示任何内容,直到前一个 /compute 路由完成,在我看来,一次只允许一个连接。问题是如何设置 Dancer2 服务器以允许多个连接,即上面提到的两个选项卡可以同时运行?
非常感谢!
【问题讨论】:
-
非常感谢我在 perldancer 网站上找不到的链接