MCPcopy
hub / github.com/celery/celery / tick

Method tick

celery/beat.py:326–364  ·  view source on GitHub ↗

Run a tick - one iteration of the scheduler. Executes one due task per call. Returns: float: preferred delay in seconds for next call.

(self, event_t=event_t, min=min, heappop=heapq.heappop,
             heappush=heapq.heappush)

Source from the content-addressed store, hash-verified

324
325 # pylint disable=redefined-outer-name
326 def tick(self, event_t=event_t, min=min, heappop=heapq.heappop,
327 heappush=heapq.heappush):
328 """Run a tick - one iteration of the scheduler.
329
330 Executes one due task per call.
331
332 Returns:
333 float: preferred delay in seconds for next call.
334 """
335 adjust = self.adjust
336 max_interval = self.max_interval
337
338 if (self._heap is None or
339 not self.schedules_equal(self.old_schedulers, self.schedule)):
340 self.old_schedulers = copy.copy(self.schedule)
341 self.populate_heap()
342
343 H = self._heap
344
345 if not H:
346 return max_interval
347
348 event = H[0]
349 entry = event[2]
350 is_due, next_time_to_run = self.is_due(entry)
351 if is_due:
352 verify = heappop(H)
353 if verify is event:
354 next_entry = self.reserve(entry)
355 self.apply_entry(entry, producer=self.producer)
356 heappush(H, event_t(self._when(next_entry, next_time_to_run),
357 event[1], next_entry))
358 return 0
359 else:
360 heappush(H, verify)
361 return min(verify[0], max_interval)
362 adjusted_next_time_to_run = adjust(next_time_to_run)
363 return min(adjusted_next_time_to_run if is_numeric_value(adjusted_next_time_to_run) else max_interval,
364 max_interval)
365
366 def schedules_equal(self, old_schedules, new_schedules):
367 if old_schedules is new_schedules is None:

Callers 1

startMethod · 0.45

Calls 8

schedules_equalMethod · 0.95
populate_heapMethod · 0.95
is_dueMethod · 0.95
reserveMethod · 0.95
apply_entryMethod · 0.95
_whenMethod · 0.95
is_numeric_valueFunction · 0.85
copyMethod · 0.80

Tested by

no test coverage detected