我在標準配置(plackup/Starman)中使用Dancer 1.31。Dancer中的線程
在請求我希望異步調用perl的功能,使請求inmmediately返回。想想典型的「長時間運行」場景,其中一個想要返回帶有刷新+重定向的「處理頁面」。
我(?天真地)試圖用一個線程:
sub myfunc {
sleep 9; # just for testing a slow operation
}
any '/test1' => sub {
my $thr = threads->create('myfunc');
$thr->detach();
return "done" ;
};
我不工作,服務器似乎停止了,錯誤日誌不顯示任何東西。我猜Dancer中禁止手動創建線程?這是PSGI的問題?推薦的方式是?
fork,而不是線程。 – MkV
@MkV是的,我明白了...你可以補充一點,作爲答案。 – leonbloy
@leonbloy,你最後做了什麼? –