File: //usr/local/lib/python3.9/site-packages/celery/events/__pycache__/dispatcher.cpython-39.pyc
a
X>h# � @ s� d Z ddlZddlZddlZddlmZmZ ddlmZ ddl m
Z
ddlmZ ddl
mZ dd lmZmZmZ d
ZG dd� d�ZdS )
zEvent dispatcher sends events.� N)�defaultdict�deque)�Producer)�app_or_default)�
anon_nodename)� utcoffset� )�Event�get_exchange�
group_from)�EventDispatcherc @ s� e Zd ZdZdhZdZdZdZd"dd�Zd d
� Z dd� Z
d
d� Zdd� Zde
fdd�Zddefdd�Zdedde
fdd�Zd#dd�Zdd� Zdd� Zdd� Zd d!� Zeee�ZdS )$r a0 Dispatches event messages.
Arguments:
connection (kombu.Connection): Connection to the broker.
hostname (str): Hostname to identify ourselves as,
by default uses the hostname returned by
:func:`~celery.utils.anon_nodename`.
groups (Sequence[str]): List of groups to send events for.
:meth:`send` will ignore send requests to groups not in this list.
If this is :const:`None`, all events will be sent.
Example groups include ``"task"`` and ``"worker"``.
enabled (bool): Set to :const:`False` to not actually publish any
events, making :meth:`send` a no-op.
channel (kombu.Channel): Can be used instead of `connection` to specify
an exact channel to use when sending events.
buffer_while_offline (bool): If enabled events will be buffered
while the connection is down. :meth:`flush` must be called
as soon as the connection is re-established.
Note:
You need to :meth:`close` this after use.
ZsqlNTr � c
C s4 t |p
| j�| _|| _|| _|p$t� | _|| _|
p6t� | _|| _ || _
tt�| _
t�� | _d | _t� | _|pt| jjj| _t� | _t� | _t|p�g �| _tj tj g| _| jj| _| | _ |s�|r�|jj!| _|| _"| jp�| j�#� }
t$|
| jjj%d�| _&|
j'j(| j)v �r
d| _"| j"�r| �*� d| ji| _+t,�-� | _.d S )N)�nameF�hostname)/r �app�
connection�channelr r �buffer_while_offline� frozenset�buffer_group�buffer_limit�on_send_bufferedr �list�
_group_buffer� threading�Lock�mutex�producerr �_outbound_buffer�confZevent_serializer�
serializer�set�
on_enabled�on_disabled�groups�time�timezone�altzone�tzoffset�clock�
delivery_mode�client�enabledZconnection_for_writer
Zevent_exchange�exchange� transportZdriver_type�DISABLED_TRANSPORTS�enable�headers�os�getpid�pid)�selfr r r, r r r r r$ r* r r r Zconninfo� r6 �B/usr/local/lib/python3.9/site-packages/celery/events/dispatcher.py�__init__: s@
�zEventDispatcher.__init__c C s | S �Nr6 �r5 r6 r6 r7 � __enter__^ s zEventDispatcher.__enter__c G s | � � d S r9 )�close)r5 �exc_infor6 r6 r7 �__exit__a s zEventDispatcher.__exit__c C s: t | jp| j| j| jdd�| _d| _| jD ]
}|� q*d S )NF)r- r Zauto_declareT)r r r r- r r r, r"