File: //usr/local/lib/python3.9/site-packages/celery/events/__pycache__/state.cpython-39.pyc
a
X>h0d � @ s� d Z ddlZddlZddlZddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZ ddl
mZ dd lmZ dd
lmZmZ ddlmZmZ ddlmZ dd
lmZ ddlmZ ddlmZmZmZ ddl m!Z! dZ"e#ed�Z$dZ%dZ&dZ'e!e(�Z)e)j*Z+dZ,dZ-dZ.ej/ej0ej1ej2ej3ej4ej5ej6d�Z7G dd� de�Z8e�9e8� eddd� d�d d!� �Z:d"e%e
e;e<fd#d$�Z=d%d&� Z>d'd(� Z?e?d)�G d*d+� d+��Z@e?d,�G d-d.� d.��ZAG d/d0� d0�ZBd1d2� ZCd3d4� ZDdS )5a� In-memory representation of cluster state.
This module implements a data-structure used to keep
track of the state of a cluster of workers and the tasks
it is working on (by consuming events).
For every event consumed the state is updated,
so the state represents the state of the cluster
at the time of the last event.
Snapshots (:mod:`celery.events.snapshot`) can be used to
take "pictures" of this state at regular intervals
to for example, store that in a database.
� N)�defaultdict)�Callable)�datetime)�Decimal)�islice)�
itemgetter)�time)�Mapping�Optional)�WeakSet�ref�� timetuple)�cached_property)�states)�LRUCache�memoize�pass1)�
get_logger)�Worker�Task�State�heartbeat_expires�pypy_version_info�� � zmSubstantial drift from %s may mean clocks are out of sync. Current drift is %s seconds. [orig: %s recv: %s]z4<State: events={0.event_count} tasks={0.task_count}>z9<Worker: {0.hostname} ({0.status_string} clock:{0.clock})z4<Task: {0.name}({0.uuid}) {0.state} clock:{0.clock}>)�sent�received�started�failed�retried� succeeded�revoked�rejectedc s( e Zd ZdZ� fdd�Zdd� Z� ZS )�CallableDefaultdicta� :class:`~collections.defaultdict` with configurable __call__.
We use this for backwards compatibility in State.tasks_by_type
etc, which used to be a method but is now an index instead.
So you can do::
>>> add_tasks = state.tasks_by_type['proj.tasks.add']
while still supporting the method call::
>>> add_tasks = list(state.tasks_by_type(
... 'proj.tasks.add', reverse=True))
c s || _ t� j|i |�� d S �N)�fun�super�__init__)�selfr&