Changeset 165
- Timestamp:
- 10/07/09 20:34:09 (7 weeks ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 modified
-
CHANGES (modified) (1 diff)
-
MANIFEST (modified) (1 diff)
-
lib/TheSchwartz/Job.pm (modified) (4 diffs)
-
lib/TheSchwartz/Worker.pm (modified) (1 diff)
-
t/declined.t (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/CHANGES
r141 r165 1 - Add $job->declined method for workers to be able to decline handling 2 a job at this time. 3 1 4 1.08 () 2 5 - Added $client->grab_and_work_on($handle) to securely work on a job -
trunk/MANIFEST
r145 r165 43 43 t/coalesce.t 44 44 t/dead-dbs.t 45 t/declined.t 45 46 t/empty-db.t 46 47 t/evenly-distribute.t -
trunk/lib/TheSchwartz/Job.pm
r163 r165 162 162 } 163 163 164 sub was_declined { 165 my $job = shift; 166 if (@_) { 167 $job->{__was_declined} = shift; 168 } 169 return $job->{__was_declined}; 170 } 171 172 164 173 sub did_something { 165 174 my $job = shift; … … 194 203 } 195 204 $job->_failed($msg, $ex_status, 0); 205 } 206 207 sub declined { 208 my ($job) = @_; 209 if ($job->did_something) { 210 $job->debug("can't call 'declined' on already finished job"); 211 return 0; 212 } 213 $job->debug("job declined. retry will be considered after lease is up at " . $job->grabbed_until); 214 215 $job->was_declined(1); 216 217 # we do nothing regarding the job's status 196 218 } 197 219 … … 444 466 or loaded, setting whether it has to C<$value> first, if specified. 445 467 468 =head2 C<$job-E<gt>was_declined()> 469 470 Sets (if given an argument) and returns the value of the was_declined flag for 471 a job object. See also C<$job-E<gt>declined()> 472 446 473 =head2 C<$job-E<gt>debug( $msg )> 447 474 … … 486 513 as C<$exit_status> (or C<1>), and the job is removed from the queue. 487 514 515 =head2 C<$job-E<gt>declined()> 516 517 Report that the job has been declined for handling at this time, which means that 518 the job will be retried after the next grabbed_until interval, and does not count 519 against the max_retries count. 520 488 521 =head2 C<$job-E<gt>replace_with( @jobs )> 489 522 -
trunk/lib/TheSchwartz/Worker.pm
r134 r165 30 30 $res = $class->work($job); 31 31 }; 32 my $errstr = $@; 32 33 33 34 my $cjob = $client->current_job; 34 if ($ @) {35 $job->debug("Eval failure: $ @");35 if ($errstr) { 36 $job->debug("Eval failure: $errstr"); 36 37 $cjob->failed($@); 37 38 } 38 unless ($cjob->did_something) {39 if (! $cjob->was_declined && ! $cjob->did_something) { 39 40 $cjob->failed('Job did not explicitly complete, fail, or get replaced'); 40 41 }
