控制Fork Super队列的长度 [英] Control the length of Fork Super queue

查看:71
本文介绍了控制Fork Super队列的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

继续我的最后一个问题跨多个哈希的访问元素数组哈希

Continuing from my last question Access element across multiple hash of hash of arrays

我有这段代码,

use Forks::Super;
foreach my $special_type (keys %test_variables) {
        my $last_job = undef;
        foreach my $test_module (keys %{$test_variables{$special_type}}) {
                foreach my $set_of_tests ($test_variables{$special_type}{$test_module}) {
                        foreach my $test (@$set_of_tests){
                                print "Starting $test\n";
                                my $job = fork {
                                    name => "$special_type/$test_module/$test",
                                    cmd => "nosetests -m $special_type/$test_module/$test",
                                    depend_on => $last_job
                                };
                                $last_job = "$special_type/$test_module/$test";
                                print "Queue last job:$last_job \n\n\n\n";
                        }
                }
        }
}

,但是形成的队列长度似乎固定为1. 因此,基本上只有第二个过程等待第一个过程完成.

but the length of the queue that is formed seems to be fixed at 1. So basically only the second process waits for the first one to get completed.

尽管我曾想过/希望建立完整的队列,例如5等待4,4等待3,3等待2,2等待1.

Though I had imagined/wished that the full queue to be built like 5 waits for 4 , 4 waits for 3 , and 3 wait for 2 and 2 waits for 1.

问题:如何从一开始就构建整个队列?

Question : How do I build the whole queue right at the start?

推荐答案

$Forks::Super::ON_BUSY设置为queue或使用类似模块

Set $Forks::Super::ON_BUSY to queue or use the module like

use Forks::Super ON_BUSY => 'queue';

默认设置为block,它将在您第一次设置具有依赖项的作业时停止执行.

The default setting is block, which would stop execution the first time you set up a job with a dependency.

对于具有依赖性的作业,也许queue应该是默认值,或者至少它应该是默认值.

Maybe queue should be the default, or at least it should be the default for jobs with dependencies.

这篇关于控制Fork Super队列的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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