File: //usr/local/lib/python3.9/site-packages/celery/events/__pycache__/snapshot.cpython-39.pyc
a
X>h� � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZ ddl
mZ dd lmZ d
Zed�ZG dd
� d
�Zddd�ZdS )aS Periodically store events in a database.
Consuming the events as a stream isn't always suitable
so this module implements a system to take snapshots of the
state of a cluster at regular intervals. There's a full
implementation of this writing the snapshots to a database
in :mod:`djcelery.snapshots` in the `django-celery` distribution.
� )�TokenBucket)� platforms)�app_or_default)�Signal)�instantiate)�
get_logger)�rate)�Timer)�Polaroid�evcamzcelery.evcamc @ s� e Zd ZdZdZeddhd�Zedd�ZdZdZ dZ
ddd�Zd
d� Zdd� Z
dd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� ZdS ) r
zRecord event snapshots.N�shutter_signal�state)�nameZproviding_args�cleanup_signal)r F� �?� �@c C sJ t |�| _|| _|| _|| _|p*| jp*t� | _t| _|oBtt |��| _
d S �N)r �appr
�freq�cleanup_freq�timerr �loggerr r �maxrate)�selfr
r r r r r � r �@/usr/local/lib/python3.9/site-packages/celery/events/snapshot.py�__init__# s
zPolaroid.__init__c C s, | j �| j| j�| _| j �| j| j�| _d S r )r Zcall_repeatedlyr �capture�_trefr �cleanup�_ctref�r r r r �install- s �zPolaroid.installc C s d S r r )r r
r r r �
on_shutter3 s zPolaroid.on_shutterc C s d S r r r! r r r �
on_cleanup6 s zPolaroid.on_cleanupc C s&