
    hqE                         S SK r S SKrS SKrS SKrS SKJrJrJr  S SKJ	r	  \R                  " S5      rS r\" S5      r\" 5       r " S S5      rS rg)	    N)async_to_synciscoroutinefunctionsync_to_async)func_accepts_kwargszdjango.dispatchc                     [        U S5      (       a*  [        U R                  5      [        U R                  5      4$ [        U 5      $ )N__func__)hasattrid__self__r   )targets    L/var/www/html/env/lib/python3.13/site-packages/django/dispatch/dispatcher.py_make_idr      s6    vz""6??#R%899f:    c                   t    \ rS rSrSrSS jrSS jrSS jrSS jrS r	S	 r
S
 rS rS rS rS rSS jrSrg)Signal   zr
Base class for all signals

Internal attributes:

    receivers
        { receiverkey (id) : weakref(receiver) }
c                     / U l         [        R                  " 5       U l        Xl        U(       a  [
        R                  " 5       O0 U l        SU l        g)z
Create a new signal.
FN)		receivers	threadingLocklockuse_cachingweakrefWeakKeyDictionarysender_receivers_cache_dead_receivers)selfr   s     r   __init__Signal.__init__#   sA     NN$	& FQg&?&?&AVX#$r   Nc                 N  ^	 SSK Jn  UR                  (       aG  UR                  (       a6  [	        U5      (       d  [        S5      e[        U5      (       d  [        S5      eU(       a  U[        U5      4m	O[        U5      [        U5      4m	[        U5      nU(       ax  [        R                  nUn[        US5      (       a-  [        US5      (       a  [        R                  nUR                  nU" U5      n[        R                  " XR                   5        U R"                     U R%                  5         ['        U	4S jU R(                   5       5      (       d  U R(                  R+                  T	X45        U R,                  R/                  5         SSS5        g! , (       d  f       g= f)	aF  
Connect receiver to sender for signal.

Arguments:

    receiver
        A function or an instance method which is to receive signals.
        Receivers must be hashable objects. Receivers can be
        asynchronous.

        If weak is True, then receiver must be weak referenceable.

        Receivers must be able to accept keyword arguments.

        If a receiver is connected with a dispatch_uid argument, it
        will not be added if another receiver was already connected
        with that dispatch_uid.

    sender
        The sender to which the receiver should respond. Must either be
        a Python object, or None to receive events from any sender.

    weak
        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
        An identifier used to uniquely identify a particular instance of
        a receiver. This will usually be a string, though it may be
        anything hashable.
r   )settingsz"Signal receivers must be callable.z:Signal receivers must accept keyword arguments (**kwargs).r   r   c              3   4   >#    U  H  u  n  o!T:H  v   M     g 7fN ).0r_key_
lookup_keys      r   	<genexpr>!Signal.connect.<locals>.<genexpr>s   s     Mn{ua
*n   N)django.confr!   
configuredDEBUGcallable	TypeErrorr   
ValueErrorr   r   r   refr	   
WeakMethodr   finalize_remove_receiverr   _clear_dead_receiversanyr   appendr   clear)
r   receiversenderweakdispatch_uidr!   is_asyncr2   receiver_objectr(   s
            @r   connectSignal.connect2   s6   D 	) 8>>H%% DEE&x00 P  &(89J"8,hv.>?J&x0++C&Ox,,:1N1N(("*"3"38}H_.C.CDYY&&(MdnnMMM%%z8&FG''--/	 YYs   !A,F
F$c                    U(       a  U[        U5      4nO[        U5      [        U5      4nSnU R                     U R                  5         [        [	        U R
                  5      5       H)  nU R
                  U   tpxXt:X  d  M  SnU R
                  U	   O   U R                  R                  5         SSS5        U$ ! , (       d  f       U$ = f)a  
Disconnect receiver from sender for signal.

If weak references are used, disconnect need not be called. The receiver
will be removed from dispatch automatically.

Arguments:

    receiver
        The registered receiver to disconnect. May be none if
        dispatch_uid is specified.

    sender
        The registered sender to disconnect

    dispatch_uid
        the unique identifier of the receiver to disconnect
FTN)r   r   r6   rangelenr   r   r9   )	r   r:   r;   r=   r(   disconnectedindexr&   r'   s	            r   
disconnectSignal.disconnectw   s    & &(89J"8,hv.>?JYY&&(s4>>23 NN51	&#'Lu- 4 ''--/   Y s   AB:-B::
C	c                 b    U R                  U5      u  p#[        U5      =(       d    [        U5      $ r#   )_live_receiversbool)r   r;   sync_receiversasync_receiverss       r   has_listenersSignal.has_listeners   s*    *.*>*>v*F'N#<tO'<<r   c                 N  ^ ^^^ T R                   (       a"  T R                  R                  T5      [        L a  / $ / nT R	                  T5      u  nmU H   nU" ST TS.TD6nUR                  XV45        M"     T(       a(  UUU U4S jnUR                  [        U5      " 5       5        U$ )a  
Send signal from sender to all connected receivers.

If any receiver raises an error, the error propagates back through send,
terminating the dispatch loop. So it's possible that all receivers
won't be called if an error is raised.

If any receivers are asynchronous, they are called after all the
synchronous receivers via a single call to async_to_sync(). They are
also executed concurrently with asyncio.gather().

Arguments:

    sender
        The sender of the signal. Either a specific object or None.

    named
        Named arguments which will be passed to receivers.

Return a list of tuple pairs [(receiver, response), ... ].
signalr;   c                  v   >#    [         R                  " UUU4S jT 5       6 I S h  vN n [        TU 5      $  N7f)Nc              3   :   >#    U  H  nU" STTS .TD6v   M     g7frQ   Nr$   r$   r%   r:   namedr   r;   s     r   r)   -Signal.send.<locals>.asend.<locals>.<genexpr>   s'      (7H !EVEuE(7   asynciogatherzip)async_responsesrM   rW   r   r;   s    r   asendSignal.send.<locals>.asend   s:     (/(7) # ?O<<#s   #979r$   )r   r   getNO_RECEIVERSrJ   r8   extendr   )	r   r;   rW   	responsesrL   r:   responser_   rM   s	   ```     @r   sendSignal.send   s    . **..v6,FI	*.*>*>v*F'&HDtFDeDHh12 ' = = ]5134r   c                   ^ ^^^#    T R                   (       a"  T R                  R                  T5      [        L a  / $ T R	                  T5      u  mnT(       a  [
        UU UU4S j5       nOS n[        R                  " U" 5       [        R                  " UU U4S jU 5       6 5      I Sh  vN u  pVUR                  [        X65      5        U$  N"7f)a  
Send signal from sender to all connected receivers in async mode.

All sync receivers will be wrapped by sync_to_async()
If any receiver raises an error, the error propagates back through
send, terminating the dispatch loop. So it's possible that all
receivers won't be called if an error is raised.

If any receivers are synchronous, they are grouped and called behind a
sync_to_async() adaption before executing any asynchronous receivers.

If any receivers are asynchronous, they are grouped and executed
concurrently with asyncio.gather().

Arguments:

    sender
        The sender of the signal. Either a specific object or None.

    named
        Named arguments which will be passed to receivers.

Return a list of tuple pairs [(receiver, response), ...].
c                  X   > / n T H   nU" STTS.TD6nU R                  X45        M"     U $ NrQ   r$   )r8   )rd   r:   re   rW   r   r;   rL   s      r   	sync_sendSignal.asend.<locals>.sync_send   s?    	 .H'LtFLeLH$$h%9: !/ ! r   c                     #    / $ 7fr#   r$   r$   r   r   rk   rl      
     	   c              3   :   >#    U  H  nU" STTS .TD6v   M     g7frU   r$   rV   s     r   r)   Signal.asend.<locals>.<genexpr>   s'      $3 ADA5A$3rY   N
r   r   ra   rb   rJ   r   r[   r\   rc   r]   )r   r;   rW   rM   rk   rd   r^   rL   s   ```    @r   r_   Signal.asend   s     4 **..v6,FI*.*>*>v*F'! ! ,3>>KNN$3,
 &
"	 	_>?&
s   B#C)C*#Cc                 D    [         R                  SUR                  UUS9  g )Nz-Error calling %s in Signal.send_robust() (%s))exc_info)loggererror__qualname__)r   r:   errs      r   _log_robust_failureSignal._log_robust_failure  s%    ;!!	 	 	
r   c                   ^ ^^^	^
 T R                   (       a"  T R                  R                  T5      [        L a  / $ / nT R	                  T5      u  nm
U H!  n U" ST TS.TD6nUR                  XV45        M#     T
(       a.  UU U4S jm	U	U
4S jnUR                  [        U5      " 5       5        U$ ! [         a.  nT R                  XW5        UR                  XW45         SnAM  SnAff = f)a  
Send signal from sender to all connected receivers catching errors.

If any receivers are asynchronous, they are called after all the
synchronous receivers via a single call to async_to_sync(). They are
also executed concurrently with asyncio.gather().

Arguments:

    sender
        The sender of the signal. Can be any Python object (normally one
        registered with a connect if you actually want something to
        occur).

    named
        Named arguments which will be passed to receivers.

Return a list of tuple pairs [(receiver, response), ... ].

If any receiver raises an error (specifically any subclass of
Exception), return the error instance as the result for that receiver.
rQ   Nc                    >#     U " STTS.TD6I S h  vN nU$  N! [          a  nTR                  X5        Us S nA$ S nAff = f7frj   	Exceptionrz   r:   re   ry   rW   r   r;   s      r   asend_and_wrap_exception4Signal.send_robust.<locals>.asend_and_wrap_exception:  sQ     %-%RT&%RE%RRH  	  S  ,,X;J8   A  A 
A>AAAAc                  r   >#    [         R                  " U4S jT 5       6 I S h  vN n [        TU 5      $  N7f)Nc              3   4   >#    U  H  nT" U5      v   M     g 7fr#   r$   r%   r:   r   s     r   r)   4Signal.send_robust.<locals>.asend.<locals>.<genexpr>D  s       (7H 1::(7r+   rZ   )r^   r   rM   s    r   r_   !Signal.send_robust.<locals>.asendB  s:     (/(7) # ?O<<#s   !757r$   )
r   r   ra   rb   rJ   r8   r   rz   rc   r   )r   r;   rW   rd   rL   r:   re   ry   r_   r   rM   s   ```      @@r   send_robustSignal.send_robust  s    0 **..v6,FI 	*.*>*>v*F'&H7#H4H%H
   (!56 '  = ]51343  2((7  (112s   B//
C'9#C""C'c                   ^ ^^^^#    T R                   (       a"  T R                  R                  T5      [        L a  / $ T R	                  T5      u  mnT(       a  [
        UU UU4S j5       nOS nUU U4S jm[        R                  " U" 5       [        R                  " U4S jU 5       6 5      I Sh  vN u  pVUR                  [        X65      5        U$  N"7f)a  
Send signal from sender to all connected receivers catching errors.

If any receivers are synchronous, they are grouped and called behind a
sync_to_async() adaption before executing any asynchronous receivers.

If any receivers are asynchronous, they are grouped and executed
concurrently with asyncio.gather.

Arguments:

    sender
        The sender of the signal. Can be any Python object (normally one
        registered with a connect if you actually want something to
        occur).

    named
        Named arguments which will be passed to receivers.

Return a list of tuple pairs [(receiver, response), ... ].

If any receiver raises an error (specifically any subclass of
Exception), return the error instance as the result for that receiver.
c                     > / n T H!  n U" STTS.TD6nU R                  X45        M#     U $ ! [         a.  nTR                  X5        U R                  X45         S nAMZ  S nAff = frj   )r8   r   rz   )rd   r:   re   ry   rW   r   r;   rL   s       r   rk   &Signal.asend_robust.<locals>.sync_sends  sy    	 .H?#+#P4#P%#P
 "((()=> !/ !  % :00?!(((99:s   -
A%#A  A%c                     #    / $ 7fr#   r$   r$   r   r   rk   r     rn   ro   c                    >#     U " STTS.TD6I S h  vN nU$  N! [          a  nTR                  X5        Us S nA$ S nAff = f7frj   r~   r   s      r   r   5Signal.asend_robust.<locals>.asend_and_wrap_exception  sQ     !)!Nf!N!NN O	 O ((7
r   c              3   4   >#    U  H  nT" U5      v   M     g 7fr#   r$   r   s     r   r)   &Signal.asend_robust.<locals>.<genexpr>  s     U_*844_r+   Nrr   )	r   r;   rW   rM   rk   rd   r^   r   rL   s	   ```    @@r   asend_robustSignal.asend_robustN  s     4 **..v6,FI +/*>*>v*F'
! 
!	 ,3>>KNNU_U,
 &
"	 	_>?&
s   B)C0C1#Cc                     U R                   (       aY  SU l         U R                   Vs/ s H4  n[        US   [        R                  5      (       a  US   " 5       c  M2  UPM6     snU l        g g s  snf )NF   )r   r   
isinstancer   ReferenceType)r   rs     r   r6   Signal._clear_dead_receivers  sa    #(D  'A"1Q4)>)>??AaDF 'DN  s   1A,A,c                 :   SnU R                   (       a9  U R                  (       d(  U R                  R                  U5      nU[        L a  / / 4$ Uc  U R
                     U R                  5         [        U5      n/ nU R                   H+  u  u  pEpgU[        :X  d  XS:X  d  M  UR                  Xg45        M-     U R                   (       a)  U(       d  [        U R                  U'   OX R                  U'   SSS5        / n/ n	U H  u  pg[        U[        R                  5      (       a9  U" 5       nUb-  U(       a  U	R                  U5        MH  UR                  U5        M[  M]  U(       a  U	R                  U5        Mw  UR                  U5        M     X4$ ! , (       d  f       N= f)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   ra   rb   r   r6   r   r   NONE_IDr8   r   r   r   )
r   r;   r   	senderkey_receiverkeyr_senderkeyr:   r>   non_weak_sync_receiversnon_weak_async_receiverss
             r   rJ   Signal._live_receivers  sh    	D$8$83377?I L(2v**,$V,		GK~~C/\"g-1I!((()=> HV ##$>J33F; ?H33F;  #%#% "+H(G$9$9::#:'077A/66x@	 ( ,33H=+228< #, '@@; s   ?FAF
Fc                     SU l         g )NT)r   )r   r:   s     r   r5   Signal._remove_receiver  s      $r   )r   r   r   r   r   )F)NTN)NNNr#   )__name__
__module__rx   __firstlineno____doc__r   r@   rG   rN   rf   r_   rz   r   r   r6   rJ   r5   __static_attributes__r$   r   r   r   r      sM    %C0J"H=,\8t
=~FP,A\$r   r   c                    ^ ^ UU 4S jnU$ )aZ  
A decorator for connecting receivers to signals. Used by passing in the
signal (or list of signals) and keyword arguments to connect::

    @receiver(post_save, sender=MyModel)
    def signal_receiver(sender, **kwargs):
        ...

    @receiver([post_save, post_delete], sender=MyModel)
    def signals_receiver(sender, **kwargs):
        ...
c                    > [        T[        [        45      (       a  T H  nUR                  " U 40 TD6  M     U $ TR                  " U 40 TD6  U $ r#   )r   listtupler@   )funcskwargsrR   s     r   
_decoratorreceiver.<locals>._decorator  sN    ftUm,,		$)&)   NN4*6*r   r$   )rR   r   r   s   `` r   r:   r:     s     r   )r[   loggingr   r   asgiref.syncr   r   r   django.utils.inspectr   	getLoggerrv   r   r   objectrb   r   r:   r$   r   r   <module>r      sV        J J 4			,	- 4. x|$ |$~r   