Changeset 1740 for trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task.pm
- Timestamp:
- 03/30/16 13:09:45 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task.pm
r1737 r1740 93 93 sub runDelay { 0; } 94 94 95 =head2 waitDelay 96 97 Return the number of second to wait before next run even there is a change in database. 98 99 Return 0 but can be override by Task module. 100 101 =cut 102 103 sub waitDelay { 0; } 104 105 =head2 needToBeRun 106 107 Return TRUE is the module has to be run or not. 108 109 =cut 110 111 sub needToBeRun { 112 my ($self, $Sync, $module) = @_; 113 114 my ($lastrev, $lastRunTime) = $Sync->get_last_rev($module); 115 116 my $currentrev = $Sync->dbrev; 117 my $currentTime = time; 118 119 if ($currentTime < $lastRunTime + $self->waitDelay) { 120 la_log LA_DEBUG, "Too early to run this module now"; 121 return 0; 122 } 123 124 if ($self->needupd($lastrev, $currentrev, $Sync)) { 125 return 1; 126 } else { 127 la_log LA_DEBUG, "No change on main base, cheking delay"; 128 } 129 130 131 if (my $delay = $self->runDelay) { 132 if ($currentTime >= $lastRunTime + $self->runDelay) { 133 return 1; 134 } else { 135 la_log LA_DEBUG, "Too short delay to run self, waiting"; 136 } 137 } 138 139 return 0; 140 } 141 95 142 =head2 run 96 143
Note: See TracChangeset
for help on using the changeset viewer.