| 1 | package TaskPipe::ThreadManager; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 40 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 40 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 40 | ▶ | use Log::Log4perl; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 40 | ▶ | use Digest::MD5 qw(md5_base64); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 40 | ▶ | use TaskPipe::RunInfo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 40 | ▶ | use Module::Runtime 'require_module'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 40 | ▶ | use TaskPipe::LoggerManager; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 40 | ▶ | use TaskPipe::SchemaManager; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 40 | ▶ | use TryCatch; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 40 | ▶ | use Proc::ProcessTable; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 40 | ▶ | use Proc::Exists qw(pexists); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 40 | ▶ | use DateTime; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 40 | ▶ | use Carp qw(confess longmess); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 40 | with 'MooseX::ConfigCascade'; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 40 | has utils => (is => 'ro', isa => 'TaskPipe::TaskUtils'); | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | has logger_manager => (is => 'ro', isa => 'TaskPipe::LoggerManager', default => sub{ | ||||||||||||||||||||||||||||
| 24 | 1 | ▶ | TaskPipe::LoggerManager->new; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 40 | }); | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | has run_info => (is => 'rw', isa => 'TaskPipe::RunInfo', default => sub{ | ||||||||||||||||||||||||||||
| 28 | 316 | ▶ | TaskPipe::RunInfo->new; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 40 | }); | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | has settings => (is => 'rw', isa => __PACKAGE__.'::Settings', default => sub{ | ||||||||||||||||||||||||||||
| 33 | 316 | ▶ | my $module = __PACKAGE__.'::Settings'; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | 316 | require_module( $module ); | |||||||||||||||||||||||||||
| 35 | 316 | my $settings = $module->new; | |||||||||||||||||||||||||||
| 36 | 316 | return $settings; | |||||||||||||||||||||||||||
| 37 | 40 | }); | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 40 | has gm => (is => 'rw', isa => 'TaskPipe::SchemaManager', required => 1); | |||||||||||||||||||||||||||
| 41 | 40 | has sm => (is => 'rw', isa => 'TaskPipe::SchemaManager', required => 1); | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | sub init{ | ||||||||||||||||||||||||||||
| 45 | 315 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 315 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||
| 48 | 315 | $SIG{CHLD} = 'IGNORE'; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | # print "run info: ".Dumper( $self->run_info )."\n"; | ||||||||||||||||||||||||||||
| 51 | # print longmess("Stack Trace: "); | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 315 | ▶ | confess "Need a job id" unless +$self->run_info->job_id; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 315 | my $conf = MooseX::ConfigCascade::Util->conf; | |||||||||||||||||||||||||||
| 56 | 315 | my $conf_serialized = $self->utils->serialize( $conf ); | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 315 | my $job_row = $self->gm->table('job')->find({ | |||||||||||||||||||||||||||
| 59 | id => $self->run_info->job_id | ||||||||||||||||||||||||||||
| 60 | }); | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 315 | ▶ | confess "Could not find a row on the job table with job id ".$self->run_info->job_id unless $job_row; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 315 | $job_row->update({ | |||||||||||||||||||||||||||
| 65 | conf => $conf_serialized | ||||||||||||||||||||||||||||
| 66 | }); | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 315 | my $thread_count = $self->sm->table('thread')->search({})->count; | |||||||||||||||||||||||||||
| 69 | 315 | $self->top_up_thread_slots; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | # judge (and return) the run situation from the state of the | ||||||||||||||||||||||||||||
| 72 | # thread table | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 315 | ▶ | return "start" unless $thread_count; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 194 | $self->sm->table('thread')->search({ | |||||||||||||||||||||||||||
| 77 | data => undef | ||||||||||||||||||||||||||||
| 78 | })->update({ | ||||||||||||||||||||||||||||
| 79 | status => 'available' | ||||||||||||||||||||||||||||
| 80 | }); | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 194 | my $resume_threads = $self->sm->table('thread')->search({ | |||||||||||||||||||||||||||
| 83 | data => { '!=', undef } | ||||||||||||||||||||||||||||
| 84 | }); | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 194 | ▶ | if ( $resume_threads->count ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 117 | $resume_threads->update({ | |||||||||||||||||||||||||||
| 88 | status => 'ready' | ||||||||||||||||||||||||||||
| 89 | }); | ||||||||||||||||||||||||||||
| 90 | 117 | return "resume"; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 77 | return "stop"; | |||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | # my $max_threads = $self->settings->max_threads; | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | # my $resume_threads = $self->sm->table('thread')->search({}); | ||||||||||||||||||||||||||||
| 103 | # my $num_resume_threads = $resume_threads->count; | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | # if ( $max_threads > $num_resume_threads ){ | ||||||||||||||||||||||||||||
| 106 | # my $start = $num_resume_threads + 1; | ||||||||||||||||||||||||||||
| 107 | # | ||||||||||||||||||||||||||||
| 108 | # for my $id ($start..$max_threads){ | ||||||||||||||||||||||||||||
| 109 | # $self->sm->table('thread')->create({ | ||||||||||||||||||||||||||||
| 110 | # id => $id, | ||||||||||||||||||||||||||||
| 111 | # status => 'available' | ||||||||||||||||||||||||||||
| 112 | # }); | ||||||||||||||||||||||||||||
| 113 | # } | ||||||||||||||||||||||||||||
| 114 | # } | ||||||||||||||||||||||||||||
| 115 | #} | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | sub manage{ | ||||||||||||||||||||||||||||
| 122 | 238 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
manage: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 238 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||
| 125 | 238 | my $count; | |||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 238 | $logger->trace("Starting manage subroutine"); | |||||||||||||||||||||||||||
| 128 | 238 | $logger->info("pid $$ started manage sub"); | |||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 40 | ▶ | use Carp 'longmess'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 131 | 238 | $logger->info("manage: ".longmess("trace:")); | |||||||||||||||||||||||||||
| 132 | # do { | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 238 | while(1){ | |||||||||||||||||||||||||||
| 135 | 363084 | $self->top_up_thread_slots; | |||||||||||||||||||||||||||
| 136 | 363084 | $self->start_forks; | |||||||||||||||||||||||||||
| 137 | 363059 | $self->clean_thread_table; | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 363059 | $count = $self->sm->table('thread')->search({ | |||||||||||||||||||||||||||
| 140 | status => 'available' | ||||||||||||||||||||||||||||
| 141 | }); | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 363059 | ▶ | if ( $count == +$self->settings->max_threads ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 213 | sleep 1; | |||||||||||||||||||||||||||
| 145 | 213 | $count = $self->sm->table('thread')->search({ | |||||||||||||||||||||||||||
| 146 | status => 'available' | ||||||||||||||||||||||||||||
| 147 | }); | ||||||||||||||||||||||||||||
| 148 | 213 | ▶ | last if $count == +$self->settings->max_threads; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | # } while ( $count <= +$self->settings->max_threads ); | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 213 | $logger->debug("Leaving manage subroutine"); | |||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | sub request_process{ | ||||||||||||||||||||||||||||
| 165 | 121 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
request_process: called CC=9 SCAR=25.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 121 | ▶ | confess "Need a job id" unless $self->run_info->job_id; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 121 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 121 | $logger->debug("Requesting process"); | |||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | #my $reserve_id = "reserved-".md5_base64( $$ * rand ); | ||||||||||||||||||||||||||||
| 174 | 121 | my $token = md5_base64( $$ * rand ); | |||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 121 | my $deadlock; | |||||||||||||||||||||||||||
| 177 | 121 | my $counter = 0; | |||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 121 | ▶ | do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$deadlock and $counter < $self->settings->thread_table_deadlock_retries
MC/DC0%0/2
$deadlock and $counter < $self->settings->thread_table_deadlock_retries
$deadlock
$counter < $self->settings->thread_table_deadlock_retries
Truth table33%1/3
A and B
A= $deadlockB= $counter < $self->settings->thread_table_deadlock_retries
| |||||||||||||||||||||||||||||
| 180 | 121 | $deadlock = ''; | |||||||||||||||||||||||||||
| 181 | 40 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | $self->gm->schema->txn_do( sub{ | ||||||||||||||||||||||||||||
| 184 | 121 | ▶ | my $rs = $self->sm->table('thread')->search({ | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 185 | status => 'available' | ||||||||||||||||||||||||||||
| 186 | }, | ||||||||||||||||||||||||||||
| 187 | { | ||||||||||||||||||||||||||||
| 188 | rows => 1, | ||||||||||||||||||||||||||||
| 189 | 'for' => 'update', | ||||||||||||||||||||||||||||
| 190 | order_by => { -asc => 'id' } | ||||||||||||||||||||||||||||
| 191 | }); | ||||||||||||||||||||||||||||
| 192 | 121 | $rs->update({ | |||||||||||||||||||||||||||
| 193 | token => $token, | ||||||||||||||||||||||||||||
| 194 | status => 'reserved' | ||||||||||||||||||||||||||||
| 195 | }); | ||||||||||||||||||||||||||||
| 196 | 121 | }); | |||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 40 | ▶ | } catch ( DBIx::Error::SerializationFailure $err ) { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=2.3
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 0 | $deadlock = $err; | |||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 40 | ▶ | } catch ( DBIx::Error $err ){ | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 0 | confess "Error updating thread table. SQLSTATE = ".$err->state.":\n$err"; | |||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 0 | }; | |||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 121 | $counter++; | |||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | } while ( $deadlock && $counter < +$self->settings->thread_table_deadlock_retries ); | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 121 | ▶ | confess "Serialization failure while trying to update threads database: ".$deadlock if $deadlock; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 121 | my $row = $self->sm->table('thread')->find({ | |||||||||||||||||||||||||||
| 215 | status => 'reserved', | ||||||||||||||||||||||||||||
| 216 | token => $token | ||||||||||||||||||||||||||||
| 217 | }); | ||||||||||||||||||||||||||||
| 218 | 121 | $logger->trace("Ending request_process subroutine"); | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 121 | ▶ | return unless $row; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 121 | $row->update({ | |||||||||||||||||||||||||||
| 223 | status => 'ready' | ||||||||||||||||||||||||||||
| 224 | }); | ||||||||||||||||||||||||||||
| 225 | 121 | return $row; | |||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | #sub mark_finished{ | ||||||||||||||||||||||||||||
| 230 | # my ($self) = @_; | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | # $self->gm->table('thread')->search({ | ||||||||||||||||||||||||||||
| 233 | # pid => $$ | ||||||||||||||||||||||||||||
| 234 | # })->update({ | ||||||||||||||||||||||||||||
| 235 | # status => 'available' | ||||||||||||||||||||||||||||
| 236 | # }); | ||||||||||||||||||||||||||||
| 237 | #} | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | sub stop_threads{ | ||||||||||||||||||||||||||||
| 241 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
stop_threads: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 0 | $self->sm->table('thread')->search({})->update({ | |||||||||||||||||||||||||||
| 244 | status => 'stopping' | ||||||||||||||||||||||||||||
| 245 | }); | ||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | sub mark_finished{ | ||||||||||||||||||||||||||||
| 252 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
mark_finished: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 0 | $self->sm->table('xresult')->search({ | |||||||||||||||||||||||||||
| 255 | thread_id => +$self->run_info->thread_id | ||||||||||||||||||||||||||||
| 256 | })->delete; | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 0 | $self->sm->table('xbranch')->search({ | |||||||||||||||||||||||||||
| 259 | thread_id => +$self->run_info->thread_id | ||||||||||||||||||||||||||||
| 260 | })->delete; | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | my $thread_row = $self->sm->table('thread')->find({ | |||||||||||||||||||||||||||
| 263 | id => +$self->run_info->thread_id | ||||||||||||||||||||||||||||
| 264 | }); | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if ( $self->run_info->thread_id > +$self->settings->max_threads ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 267 | 0 | $thread_row->delete; | |||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 0 | my $spawned_row = $self->gm->table('spawned')->find({ | |||||||||||||||||||||||||||
| 270 | process_name => 'thread', | ||||||||||||||||||||||||||||
| 271 | job_id => +$self->run_info->job_id, | ||||||||||||||||||||||||||||
| 272 | thread_id => +$self->run_info->thread_id | ||||||||||||||||||||||||||||
| 273 | }); | ||||||||||||||||||||||||||||
| 274 | 0 | ▶ | $spawned_row->delete if $spawned_row; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 275 | } else { | ||||||||||||||||||||||||||||
| 276 | 0 | $thread_row->update({ | |||||||||||||||||||||||||||
| 277 | status => 'available', | ||||||||||||||||||||||||||||
| 278 | data => undef | ||||||||||||||||||||||||||||
| 279 | }); | ||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | sub terminate{ | ||||||||||||||||||||||||||||
| 290 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
terminate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | 0 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 0 | $self->mark_finished( $$ ); | |||||||||||||||||||||||||||
| 295 | 0 | $logger->debug("Terminating process $$ on thread ".$self->run_info->thread_id); | |||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | 0 | Log::Log4perl->remove_logger( $logger ); | |||||||||||||||||||||||||||
| 298 | 0 | exit; | |||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | sub execute{ | ||||||||||||||||||||||||||||
| 303 | 121 | ▶ | my ($self,$task_data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
execute: called CC=5 SCAR=18.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 304 | 121 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||
| 305 | 121 | $logger->trace("Starting execute subroutine"); | |||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 121 | ▶ | return if ($self->xbranch_seen( $task_data )); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 121 | ▶ | confess "Need task_data" unless $task_data; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | 121 | my $thread_row = $self->request_process; | |||||||||||||||||||||||||||
| 312 | 121 | $logger->trace("After request_process"); | |||||||||||||||||||||||||||
| 313 | 121 | my $xbranch; | |||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | 121 | ▶ | if ( $thread_row ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | 121 | $xbranch = $self->utils->create_xbranch_record( | |||||||||||||||||||||||||||
| 320 | $task_data, | ||||||||||||||||||||||||||||
| 321 | $thread_row->id | ||||||||||||||||||||||||||||
| 322 | ); | ||||||||||||||||||||||||||||
| 323 | 121 | unshift @{$task_data->{xbranch_ids}}, $xbranch->id; | |||||||||||||||||||||||||||
| 324 | 121 | $self->utils->add_run_info( $task_data ); | |||||||||||||||||||||||||||
| 325 | 121 | my $ds = $self->utils->serialize( $task_data ); | |||||||||||||||||||||||||||
| 326 | 121 | $thread_row->update({ data => $ds }); | |||||||||||||||||||||||||||
| 327 | } else { | ||||||||||||||||||||||||||||
| 328 | 0 | ▶ | if ( $self->thread_is_old ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 329 | 0 | $logger->debug("Thread refresh time exceeded. Restarting thread"); | |||||||||||||||||||||||||||
| 330 | 0 | $self->utils->exec_xtask_script; | |||||||||||||||||||||||||||
| 331 | } else { | ||||||||||||||||||||||||||||
| 332 | 0 | $xbranch = $self->utils->create_xbranch_record( | |||||||||||||||||||||||||||
| 333 | $task_data, | ||||||||||||||||||||||||||||
| 334 | $self->run_info->thread_id | ||||||||||||||||||||||||||||
| 335 | ); | ||||||||||||||||||||||||||||
| 336 | 0 | unshift @{$task_data->{xbranch_ids}}, $xbranch->id; | |||||||||||||||||||||||||||
| 337 | 0 | $logger->trace("Parent executing task directly"); | |||||||||||||||||||||||||||
| 338 | 0 | $self->utils->exec_task_from_data( $task_data ); | |||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | 121 | $self->sm->table('xbranch')->search({ | |||||||||||||||||||||||||||
| 342 | id => +$xbranch->id | ||||||||||||||||||||||||||||
| 343 | })->update({ | ||||||||||||||||||||||||||||
| 344 | status => 'seen' | ||||||||||||||||||||||||||||
| 345 | }); | ||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | # $xbranch->update({ status => 'seen' }); | ||||||||||||||||||||||||||||
| 348 | 121 | $logger->trace("End of execute subroutine"); | |||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | sub xbranch_seen{ | ||||||||||||||||||||||||||||
| 354 | 121 | ▶ | my ($self,$task_data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
xbranch_seen: called CC=5 SCAR=19.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 121 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||
| 357 | 121 | $logger->trace("starting xbranch_seen subroutine"); | |||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||
| 359 | my $xbranch_row = $self->sm->table('xbranch')->find({ | ||||||||||||||||||||||||||||
| 360 | plan_key => $task_data->{branch_id}, | ||||||||||||||||||||||||||||
| 361 | input_key => $task_data->{input_id} | ||||||||||||||||||||||||||||
| 362 | }, { | ||||||||||||||||||||||||||||
| 363 | 121 | key => 'plan_key' | |||||||||||||||||||||||||||
| 364 | }); | ||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | 121 | my $seen = 0; | |||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 121 | ▶ | if ( $xbranch_row ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 369 | 0 | my $status = $xbranch_row->status; | |||||||||||||||||||||||||||
| 370 | 0 | ▶ | $seen = 1 if $status && $status eq 'seen'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$status and $status eq "seen"
MC/DC0%0/2
$status and $status eq "seen"
$status
$status eq "seen"
Truth table0%0/3
A and B
A= $statusB= $status eq "seen"
| |||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | 121 | ▶ | $logger->debug("Already seen xbranch with plan key ".$task_data->{branch_id}." and input key ".$task_data->{input_id}) if $seen; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | 121 | $logger->trace("ending xbranch_seen subroutine"); | |||||||||||||||||||||||||||
| 376 | 121 | return $seen; | |||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | sub thread_is_old{ | ||||||||||||||||||||||||||||
| 383 | 0 | ▶ | my ($self,$thread_row) = @_; | ||||||||||||||||||||||||||
|
Subroutine
thread_is_old: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | 0 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | 0 | my $dt = DateTime->now; | |||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | 0 | ▶ | if ( ! $thread_row ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 390 | 0 | $thread_row = $self->sm->table('thread')->find({ | |||||||||||||||||||||||||||
| 391 | id => $self->run_info->thread_id | ||||||||||||||||||||||||||||
| 392 | }); | ||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | 0 | $logger->debug("thread_is_old: thread_id: ".$self->run_info->thread_id." job_id ".$self->run_info->job_id); | |||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | 0 | my $thread_is_old = 0; | |||||||||||||||||||||||||||
| 398 | 0 | ▶ | if ( $thread_row ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 399 | 0 | $logger->debug("Got a thread row"); | |||||||||||||||||||||||||||
| 400 | 0 | my $forked_dt = $thread_row->last_forked; | |||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | 0 | ▶ | if ( $forked_dt ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | 0 | $forked_dt->add( minutes => +$self->settings->refresh_mins ); | |||||||||||||||||||||||||||
| 405 | 0 | ▶ | $thread_is_old = 1 if ( DateTime->compare( $dt, $forked_dt ) == 1 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | $thread_row->update({ | ||||||||||||||||||||||||||||
| 410 | 0 | last_checked => $dt | |||||||||||||||||||||||||||
| 411 | }); | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | } else { | ||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | 0 | $logger->debug("No thread row"); | |||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | 0 | return $thread_is_old; | |||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | sub start_fork{ | ||||||||||||||||||||||||||||
| 425 | 238 | ▶ | my ($self,$thread_id) = @_; | ||||||||||||||||||||||||||
|
Subroutine
start_fork: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | 238 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | 238 | my $dt = DateTime->now; | |||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | 238 | my $parent_pid = $$; | |||||||||||||||||||||||||||
| 432 | $self->sm->schema->txn_do( sub{ | ||||||||||||||||||||||||||||
| 433 | 238 | ▶ | $self->sm->table('thread')->search({ | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 434 | id => $thread_id | ||||||||||||||||||||||||||||
| 435 | })->update({ | ||||||||||||||||||||||||||||
| 436 | status => 'forking', | ||||||||||||||||||||||||||||
| 437 | parent_id => +$self->run_info->thread_id, | ||||||||||||||||||||||||||||
| 438 | parent_pid => $parent_pid, | ||||||||||||||||||||||||||||
| 439 | last_forked => $dt, | ||||||||||||||||||||||||||||
| 440 | last_checked => $dt | ||||||||||||||||||||||||||||
| 441 | }); | ||||||||||||||||||||||||||||
| 442 | 238 | }); | |||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | 238 | $logger->debug("Forking"); | |||||||||||||||||||||||||||
| 445 | #$self->sm->schema->storage->disconnect; | ||||||||||||||||||||||||||||
| 446 | #$self->gm->schema->storage->disconnect; | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | 238 | my $pid = fork(); | |||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | # $self->sm( TaskPipe::SchemaManager->new ); | ||||||||||||||||||||||||||||
| 451 | # $self->sm->connect_schema; | ||||||||||||||||||||||||||||
| 452 | # $self->gm( TaskPipe::SchemaManager->new( scope => 'global' ) ); | ||||||||||||||||||||||||||||
| 453 | # $self->gm->connect_schema; | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | 238 | ▶ | confess "Fork failed" if not defined $pid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 456 | 238 | ▶ | $logger->debug("Created fork $pid") if $pid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 457 | 238 | ▶ | return $pid if $pid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | 25 | $self->run_info->thread_id( $thread_id ); | |||||||||||||||||||||||||||
| 460 | 25 | $self->logger_manager->init_logger; | |||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | $self->gm->schema->txn_do( sub{ | ||||||||||||||||||||||||||||
| 463 | 25 | ▶ | $self->gm->table('spawned')->update_or_create({ | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 464 | process_name => 'thread', | ||||||||||||||||||||||||||||
| 465 | job_id => $self->run_info->job_id, | ||||||||||||||||||||||||||||
| 466 | used_by_pid => $parent_pid, | ||||||||||||||||||||||||||||
| 467 | thread_id => $thread_id, | ||||||||||||||||||||||||||||
| 468 | status => 'processing', | ||||||||||||||||||||||||||||
| 469 | pid => $$, | ||||||||||||||||||||||||||||
| 470 | last_checked => $dt | ||||||||||||||||||||||||||||
| 471 | }); | ||||||||||||||||||||||||||||
| 472 | 25 | }); | |||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||
| 474 | 25 | $self->sm->table('thread')->find({ | |||||||||||||||||||||||||||
| 475 | id => $thread_id | ||||||||||||||||||||||||||||
| 476 | })->update({ | ||||||||||||||||||||||||||||
| 477 | status => 'processing', | ||||||||||||||||||||||||||||
| 478 | pid => $$ | ||||||||||||||||||||||||||||
| 479 | }); | ||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||
| 481 | 25 | $logger->debug("In child executing xtask script"); | |||||||||||||||||||||||||||
| 482 | 25 | $self->utils->exec_xtask_script; | |||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | sub start_forks{ | ||||||||||||||||||||||||||||
| 490 | 363084 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
start_forks: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||
| 492 | # my $processing_rs = $self->sm->table('thread')->search({ | ||||||||||||||||||||||||||||
| 493 | # status => 'processing' | ||||||||||||||||||||||||||||
| 494 | # }); | ||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | # return if ($processing_rs->count); | ||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | # my $threads_rs = $self->sm->table('thread')->search({ | ||||||||||||||||||||||||||||
| 499 | # status => 'ready' | ||||||||||||||||||||||||||||
| 500 | # }, { | ||||||||||||||||||||||||||||
| 501 | # rows => 1 | ||||||||||||||||||||||||||||
| 502 | # }); | ||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | 363084 | my $threads_rs = $self->sm->table('thread')->search({ | |||||||||||||||||||||||||||
| 505 | status => 'ready' | ||||||||||||||||||||||||||||
| 506 | }); | ||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||
| 508 | 363084 | ▶ | while ( my $thread_row = $threads_rs->next ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | #sleep 2; | ||||||||||||||||||||||||||||
| 511 | 238 | $self->start_fork( $thread_row->id ); | |||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | sub top_up_thread_slots{ | ||||||||||||||||||||||||||||
| 518 | 363399 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
top_up_thread_slots: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | 363399 | my $logger = Log::Log4perl->get_logger; | |||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | 363399 | my $taken_slots = $self->sm->table('thread')->search({},{ | |||||||||||||||||||||||||||
| 523 | order_by => 'id', | ||||||||||||||||||||||||||||
| 524 | columns => ['id'] | ||||||||||||||||||||||||||||
| 525 | }); | ||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | 363399 | my $max = $self->settings->max_threads; | |||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | 363399 | my $needed = $max - $taken_slots->count; | |||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | 363399 | ▶ | if ( $needed > 0 ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 532 | 121 | my $taken_lookup = {}; | |||||||||||||||||||||||||||
| 533 | 121 | ▶ | while( my $taken_slot = $taken_slots->next ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 534 | 0 | $taken_lookup->{ $taken_slot->id } = 1; | |||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | 121 | my $slots_to_create = []; | |||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||
| 539 | 121 | my $id = 0; | |||||||||||||||||||||||||||
| 540 | 121 | my $added = 0; | |||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | 121 | ▶ | while( $added < $needed ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 543 | 121 | $id++; | |||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||
| 545 | 121 | ▶ | if ( ! $taken_lookup->{$id} ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 546 | 121 | $self->sm->table('thread')->create({ | |||||||||||||||||||||||||||
| 547 | id => $id, | ||||||||||||||||||||||||||||
| 548 | status => 'available' | ||||||||||||||||||||||||||||
| 549 | }); | ||||||||||||||||||||||||||||
| 550 | 121 | $added++; | |||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||
| 559 | sub clean_thread_table{ | ||||||||||||||||||||||||||||
| 560 | 363059 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
clean_thread_table: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | 363059 | my $thread_rs = $self->sm->table('thread')->search({ | |||||||||||||||||||||||||||
| 563 | status => 'processing' | ||||||||||||||||||||||||||||
| 564 | }); | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | 363059 | ▶ | while( my $thread = $thread_rs->next ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | 361870 | ▶ | if ( ! pexists( $thread->pid ) ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||
| 570 | 6 | $thread->update({ | |||||||||||||||||||||||||||
| 571 | status => 'available' | ||||||||||||||||||||||||||||
| 572 | }); | ||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||
| 580 | =head1 NAME | ||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||
| 582 | TaskPipe::ThreadManager - manages threads for TaskPipe | ||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||
| 584 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||
| 586 | Using this module directly is not recommended. See the general manpages for Taskpipe. | ||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||
| 588 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||
| 590 | Tom Gracey <tomgracey@gmail.com> | ||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||
| 592 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||
| 594 | Copyright (c) Tom Gracey 2018 | ||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||
| 596 | TaskPipe is free software, licensed under | ||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||
| 598 | The GNU Public License Version 3 | ||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | =cut | ||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||
| 602 | 40 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 603 | 40 | 1; | |||||||||||||||||||||||||||