HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //usr/local/lib/python3.9/site-packages/celery/utils/dispatch/__pycache__/signal.cpython-39.pyc
a

X>h#6�@s�dZddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZddl
mZddlmZdd	lmZd
Zee�Zdd�Zd
d�Zdd�Zed�Ze�ZdZGdd�d�ZdS)z'Implementation of the Observer pattern.�N)�
WeakMethod)�retry_over_time)�CDeprecationWarning)�PromiseProxy�Proxy)�fun_accepts_kwargs)�
get_logger)�humanize_seconds)�SignalcCs@t|t�r|��}t|ttf�r$|St|d�r8t|j�St|�S)N�__func__)�
isinstancer�_get_current_object�bytes�str�hasattr�idr)�target�r�F/usr/local/lib/python3.9/site-packages/celery/utils/dispatch/signal.py�_make_ids


rcCs:z|j|jt|jfWSty4tj|fYS0dS)aGet weakref constructor appropriate for `obj`.  `obj` may be a bound method.

    Bound method objects must be special-cased because they're usually garbage
    collected immediately, even if the instance they're bound to persists.

    Returns:
        a (weakref constructor, main object) tuple. `weakref constructor` is
        either :class:`weakref.ref` or :class:`weakref.WeakMethod`.  `main
        object` is the instance that `obj` is bound to if it is a bound method;
        otherwise `main object` is simply `obj.
    N)r�__self__r�AttributeError�weakref�ref)�objrrr�_boundmethod_safe_weakref srcCs<|r|t|�fSt|d�r(|jt|�fSt|�t|�fSdS)N�
_dispatch_uid)rrr)�receiver�sender�dispatch_uidrrr�_make_lookup_key6s

r zDCould not process signal receiver %(receiver)s. Retrying %(when)s...c@s�eZdZdZdZddd�Zdd�Zdd	�Zd
d�Zddd
�Z	ddd�Z
dd�ZeZdd�Z
dd�Zddd�Zdd�Zdd�ZdS) r
aCreate new signal.

    Keyword Arguments:
        providing_args (List): A list of the arguments this signal can pass
            along in a :meth:`send` call.
        use_caching (bool): Enable receiver cache.
        name (str): Name of signal, used for debugging purposes.
    NFcCsNg|_t|dur|ng�|_t��|_||_||_|r>t�	�ni|_
d|_dS)NF)�	receivers�set�providing_args�	threading�Lock�lock�use_caching�namer�WeakKeyDictionary�sender_receivers_cache�_dead_receivers)�selfr#r'r(rrr�__init__Ws�
�zSignal.__init__cCs|j||��||d�S)N)r�weakr)�connectr
)r,�funrr.rrrr�_connect_proxyhs�zSignal._connect_proxycsJd�fdd�	}|r<t|d�r<||dd�i|��|d�S||i|��S)	a�Connect receiver to sender for signal.

        Arguments:
            receiver (Callable): A function or an instance method which is to
                receive signals.  Receivers must be hashable objects.

                if weak is :const:`True`, then receiver must be
                weak-referenceable.

                Receivers must be able to accept keyword arguments.

                If receivers have a `dispatch_uid` attribute, the receiver will
                not be added if another receiver already exists with that
                `dispatch_uid`.

            sender (Any): The sender to which the receiver should respond.
                Must either be a Python object, or :const:`None` to
                receive events from any sender.

            weak (bool): Whether to use weak references to the receiver.
                By default, the module will attempt to use weak references to
                the receiver objects.  If this parameter is false, then strong
                references will be used.

            dispatch_uid (Hashable): An identifier used to uniquely identify a
                particular instance of a receiver.  This will usually be a
                string, though it may be anything hashable.

            retry (bool): If the signal receiver raises an exception
                (e.g. ConnectionError), the receiver will be retried until it
                runs successfully. A strong ref to the receiver will be stored
                and the `weak` option will be ignored.
        NTFcs�����fdd�}|S)Ncs\��d�}dd�}�r@d|d<�s.t|�|d<||�}|d|_��|�|d|d�|S)N)rr.cs�fdd�}|S)Ncs�fdd�}t�t|||�S)Ncs,t|�}t�t|dd�d�}t�|�|S)N�in� )r�when)�next�RECEIVER_RETRY_ERRORr	�logger�error)�excZ	intervals�retries�interval�err_msg��	retry_funrr�on_error�s
��
z�Signal.connect.<locals>._handle_options.<locals>._connect_signal.<locals>._retry_receiver.<locals>._try_receiver_over_time.<locals>.on_error)r�	Exception)�args�kwargsr?r=rr�_try_receiver_over_time�s�zzSignal.connect.<locals>._handle_options.<locals>._connect_signal.<locals>._retry_receiver.<locals>._try_receiver_over_timer)r>rCrr=r�_retry_receiver�szYSignal.connect.<locals>._handle_options.<locals>._connect_signal.<locals>._retry_receiverFr.r)rr�_connect_signal)r0�optionsrD)r�retryr,rr.rrrE�s�
�[email protected].<locals>._handle_options.<locals>._connect_signalr)rr.rrGrE�r,)rrGrr.r�_handle_options�s#z'Signal.connect.<locals>._handle_optionsr�)NTNF)�callable)r,rArBrIrrHrr/ns"�(zSignal.connectc
Cs�t|�sJd��t|�s td��t|t�rB|�|j||||�|St|||�}|rtt|�\}}||�}t	�
||j�|j�N|�
�|jD]\}}	||kr�q�q�|j�||f�|j��Wd�n1s�0Y|S)Nz!Signal receivers must be callablez.Signal receiver must accept keyword arguments.)rKr�
ValueErrorrrZ__then__r1r rr�finalize�_remove_receiverr&�_clear_dead_receiversr!�appendr*�clear)
r,rrr.r�
lookup_keyrZreceiver_object�r_key�_rrrrE�s.�
�(zSignal._connect_signalc
Cs�|durtjdtdd�t|||�}d}|j�\|��tt|j��D]*}|j|\}}	||krFd}|j|=qrqF|j	�
�Wd�n1s�0Y|S)a8Disconnect receiver from sender for signal.

        If weak references are used, disconnect needn't be called.
        The receiver will be removed from dispatch automatically.

        Arguments:
            receiver (Callable): The registered receiver to disconnect.
                May be none if `dispatch_uid` is specified.

            sender (Any): The registered sender to disconnect.

            weak (bool): The weakref state to disconnect.

            dispatch_uid (Hashable): The unique identifier of the receiver
                to disconnect.
        Nz+Passing `weak` to disconnect has no effect.�)�
stacklevelFT)�warnings�warnrr r&rO�range�lenr!r*rQ)
r,rrr.rrR�disconnected�indexrSrTrrr�
disconnect�s"�(zSignal.disconnectcCst|�|��S)N)�bool�_live_receivers)r,rrrr�
has_listeners�szSignal.has_listenerscKs�g}|jr|j�|�tur|S|�|�D]�}z|f||d�|��}WnXty�}z@t|d�slt��d|_	t
�d||�|�||f�WYd}~q(d}~00|�||f�q(|S)uASend signal from sender to all connected receivers.

        If any receiver raises an error, the exception is returned as the
        corresponding response. (This is different from the "send" in
        Django signals. In Celery "send" and "send_robust" do the same thing.)

        Arguments:
            sender (Any): The sender of the signal.
                Either a specific object or :const:`None`.
            **named (Any): Named arguments which will be passed to receivers.

        Returns:
            List: of tuple pairs: `[(receiver, response), … ]`.
        )�signalr�
__traceback__rUzSignal handler %r raised: %rN)
r!r*�get�NO_RECEIVERSr_r@r�sys�exc_inforbr7�	exceptionrP)r,r�named�	responsesr�responser9rrr�sends"�
�$zSignal.sendcCsP|jrLd|_g}|jD].}t|dtj�r:|d�dur:q|�|�q||_dS)NFrJ)r+r!rr�
ReferenceTyperP)r,Z
new_receivers�rrrrrO$s
zSignal._clear_dead_receiverscCs�d}|jr(|js(|j�|�}|tur(gS|dur�|j�r|��t|�}g}|jD]&\\}}}|t	ksn||krR|�
|�qR|jr�|s�t|j|<n
||j|<Wd�n1s�0Yg}|D]4}t|tj
�r�|�}|dur�|�
|�q�|�
|�q�|S)z�Filter sequence of receivers to get resolved, live receivers.

        This checks for weak references and resolves them, then returning only
        live receivers.
        N)r'r+r*rcrdr&rOrr!�NONE_IDrPrrrl)r,rr!Z	senderkeyZreceiverkeyZr_senderkeyrZnon_weak_receiversrrrr_/s2(zSignal._live_receiverscCs
d|_dS)z'Remove dead receivers from connections.TN)r+)r,rrrrrNVszSignal._remove_receivercCs"dt|�j�d|j�d|j�d�S)z``repr(signal)``.�<z: z providing_args=�>)�type�__name__r(r#rHrrr�__repr__`szSignal.__repr__cCst|�S)z``str(signal)``.)�reprrHrrr�__str__dszSignal.__str__)NFN)NNNN)N)N)rr�
__module__�__qualname__�__doc__r!r-r1r/rEr]r`rkZsend_robustrOr_rNrsrurrrrr
Is"
N�
%
 '

r
)rxrer$rWrrZkombu.utils.functionalrZcelery.exceptionsrZcelery.localrrZcelery.utils.functionalrZcelery.utils.logrZcelery.utils.timer	�__all__rrr7rrr rn�objectrdr6r
rrrr�<module>s(