line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Proc::JobQueue::DependencyQueue; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
30603
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp qw(confess); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
7
|
|
|
|
|
|
|
require Proc::JobQueue; |
8
|
1
|
|
|
1
|
|
5
|
use Time::HiRes qw(time); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
9
|
1
|
|
|
1
|
|
107
|
use Object::Dependency; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
10
|
|
|
|
|
|
|
require POSIX; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = qw(Proc::JobQueue); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $timer_interval = 6; |
15
|
|
|
|
|
|
|
my $debug = 0; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new |
18
|
|
|
|
|
|
|
{ |
19
|
0
|
|
|
0
|
1
|
|
my ($pkg, %params) = @_; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
0
|
|
|
|
$params{dependency_graph} ||= Object::Dependency->new(); |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $queue = $pkg->SUPER::new( |
24
|
|
|
|
|
|
|
startmore_in_progress => 0, |
25
|
|
|
|
|
|
|
on_failure => \&on_failure, |
26
|
|
|
|
|
|
|
%params |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
if (defined(&IO::Event::unloop_all)) { |
30
|
0
|
|
|
|
|
|
my $last_dump = time; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $timer = IO::Event->timer( |
33
|
|
|
|
|
|
|
interval => $params{timer_interval} || $timer_interval, |
34
|
|
|
|
|
|
|
cb => sub { |
35
|
0
|
0
|
|
0
|
|
|
print STDERR "beep!\n" if $debug; |
36
|
0
|
|
|
|
|
|
eval { |
37
|
0
|
|
|
|
|
|
$queue->startmore; |
38
|
|
|
|
|
|
|
}; |
39
|
0
|
0
|
|
|
|
|
if ($@) { |
40
|
0
|
|
|
|
|
|
print STDERR "DIE DIE DIE DIE DIE (DT1): $@"; |
41
|
|
|
|
|
|
|
# exit 1; hangs |
42
|
0
|
|
|
|
|
|
POSIX::_exit(1); |
43
|
|
|
|
|
|
|
}; |
44
|
0
|
0
|
0
|
|
|
|
if ($debug && time > $last_dump + $timer_interval) { |
45
|
0
|
|
|
|
|
|
$params{dependency_graph}->dump_graph(); |
46
|
0
|
|
|
|
|
|
$last_dump = time; |
47
|
|
|
|
|
|
|
} |
48
|
1
|
|
|
1
|
|
245
|
use POSIX ":sys_wait_h"; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
49
|
0
|
|
|
|
|
|
my $k; |
50
|
0
|
|
|
|
|
|
do { $k = waitpid(-1, WNOHANG) } while $k > 0; |
|
0
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
}, |
52
|
0
|
|
0
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$Event::DIED = sub { |
55
|
0
|
|
|
0
|
|
|
Event::verbose_exception_handler(@_); |
56
|
0
|
|
|
|
|
|
IO::Event::unloop_all(); |
57
|
0
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return $queue; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub unloop |
64
|
|
|
|
|
|
|
{ |
65
|
0
|
|
|
0
|
0
|
|
my ($queue) = @_; |
66
|
0
|
0
|
|
|
|
|
if (defined(&IO::Event::unloop_all)) { |
67
|
0
|
|
|
|
|
|
IO::Event::unloop_all(); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub on_failure |
72
|
|
|
|
|
|
|
{ |
73
|
0
|
|
|
0
|
0
|
|
my ($queue, $job, @exit_code) = @_; |
74
|
0
|
0
|
|
|
|
|
if ($job->{on_failure}) { |
|
|
0
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
$job->{on_failure}->(@exit_code); |
76
|
|
|
|
|
|
|
} elsif ($job->{errors}) { |
77
|
0
|
|
|
|
|
|
$job->{errors}->("FAILED: $job->{desc}", @exit_code); |
78
|
|
|
|
|
|
|
} else { |
79
|
0
|
|
|
|
|
|
print STDERR "JOB $job->{desc} FAILED\nexit @exit_code\n"; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |