
    {kfk              
          d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl	m
Z
mZ ddlmZ ddlmZ ddlmZ dd	lmZmZ dd
lmZmZmZmZ ddlmZ ddlmZ ddlmZ ddl m!Z!m"Z"m#Z#m$Z$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1m2Z2m3Z3 dZ4ddl5m6Z6  e)e7          Z8dZ9dZ:dZ;dZ<dZ=dZ>dZ? edd          Z@ e@e>dejA        d d           ZB e@e=d!ejC        dd          ZD e@e<d"ejE        d d           ZF e@e;d#ejC        dd          ZG e@e;d$ejH        d d           ZIejJ        jK        ZLejM        jK        ZNejO        jK        ZPejQ        ZQejR        ZRejS        ZSejT        ZTejU        ZUejV        ZVejW        ZW eXeSeUeTh          ZYg ZZi Z[ ed%d&          Z\d' Z]d( Z^d) Z_d* Z` G d+ d,          Zad9d-Zbddd.ead/d/dejc        e\eYf
d0Zdd9d1Zed2 Zfedfd3Zgeddfd4Zhd5 Zid9d6Zjefd7Zkd8 ZldS ):zTrace task execution.

This module defines how the task execution is traced:
errors are recorded, handlers are applied and so on.
    N)
namedtuple)warn)ExceptionInfoExceptionWithTraceback)EncodeError)loads)prepare_accept_content)	safe_reprsafe_str)current_appgroupsignalsstates)_task_stack)Context)Task)BackendGetMetaErrorIgnoreInvalidTaskErrorRejectRetry)AsyncResult)
get_logger)gethostname)
mro_lookup)saferepr)get_pickleable_etypeget_pickleable_exceptionget_pickled_exception)	TraceInfobuild_tracer
trace_tasksetup_worker_optimizationsreset_worker_optimizations)successful_requestszTask %(name)s[%(id)s] receivedzATask %(name)s[%(id)s] succeeded in %(runtime)ss: %(return_value)sz.Task %(name)s[%(id)s] %(description)s: %(exc)sz%Task %(name)s[%(id)s] %(description)szTask %(name)s[%(id)s] %(exc)sz$Task %(name)s[%(id)s] retry: %(exc)slog_policy_t)formatdescriptionseverity	tracebackmailrejected   ignoredzINTERNAL ERRORzraised expectedzraised unexpected
trace_ok_t)retvalinforuntimeretstrc                 D    t                               | |d|i           dS )zzLog 'fmt % context' with severity 'INFO'.

    'context' is also passed in extra with key 'data' for custom handlers.
    data)extraN)loggerr1   )fmtcontexts     P/var/www/html/nettyfy-visnx/env/lib/python3.11/site-packages/celery/app/trace.pyr1   r1   {   s'    
 KKWVW$5K66666    c                 L    t          | j        |t          t          hdg          S )z+Return true if the task overrides ``attr``.zcelery.app.task)stopmonkey_patched)r   	__class__BaseTaskobject)taskattrs     r:   task_has_customrD      s,    dnd(F1C&7%8: : : :r;   c                     t          |t                    rt          S t          |t                    rt          S |j        rt          S | j        rt          || j                  rt          S t          S N)

isinstancer   log_policy_rejectr   log_policy_ignoreinternallog_policy_internalthrowslog_policy_expectedlog_policy_unexpected)rB   einfoexcs      r:   get_log_policyrQ      sk    #v 	%  	C	 	  %  	 %""; 	':c4;77 	'&&$$r;   c                 (    t          | dd          p|S )z8Use 'shadow' in request for the task name if applicable.shadowN)getattr)requestdefaults     r:   get_task_namerW      s     7Hd++6w6r;   c                   J    e Zd ZdZdZddZ	 ddZd Zd	 Zdd
Z	ddZ
d ZdS )r    z!Information about task execution.stater0   Nc                 "    || _         || _        d S rF   rY   )selfrZ   r0   s      r:   __init__zTraceInfo.__init__   s    
r;   FTc                     |j         r|j        }n|r
|j        rd}n| }	 t          | j        t
          | j        i| j                 ||||          S )NT)store_errorscall_errbacks)ignore_resultstore_errors_even_if_ignoredstore_eager_resultRETRYhandle_retryFAILUREhandle_failurerZ   )r\   rB   reqeagerr`   r_   s         r:   handle_error_statezTraceInfo.handle_error_state   s~     	%<LL 	%t. 	%LL$9L4$T(
 * C#/$13 3 3 	3r;   c                 L    |                      ||t                                 d S rF   
_log_errorr   r\   rB   rh   kwargss       r:   handle_rejectzTraceInfo.handle_reject   "    c=??33333r;   c                 L    |                      ||t                                 d S rF   rl   rn   s       r:   handle_ignorezTraceInfo.handle_ignore   rq   r;   c                    t          j                    \  }}}	 | j        }t          |||f          }	|r-|j                            |j        |j        |	j        |           |	                    |j        |j        |j
        |j        |	           t          j                            ||||	           t          t           |j        t#          ||j                  t'          |          d           |	~S # ~w xY w)zHandle retry exception.rU   )senderrU   reasonrO   )idnamerP   )sysexc_infor0   r   backendmark_as_retryrx   rP   r*   on_retryargsro   r   
task_retrysendr1   	LOG_RETRYrW   ry   str)
r\   rB   rh   r_   ro   type__tbrw   rO   s
             r:   re   zTraceInfo.handle_retry   s    |~~q"	[F!5&""566E **FFJ +    MM&*cfch
EJJJ##4+1 $ @ @ @f%c49556{{    
 FFFFs   CC2 2C5c           	      &   | j         }t          |          }|j        t          j                    \  }}|_        t          t          |                    }t          |||j        f          }	|j        	                    |j
        ||	j        |||           |                    ||j
        |j        |j        |	           t          j                            ||j
        ||j        |j        |j        |	           |                     |||	           |	S )zHandle exception.Nr{   )rU   store_resultr`   )rv   task_id	exceptionr   ro   r*   rO   )r0   r   __traceback__rz   r{   r   typer   r|   mark_as_failurerx   r*   
on_failurer   ro   r   task_failurer   rm   )
r\   rB   rh   r_   r`   orig_excrP   r   exc_typerO   s
             r:   rg   zTraceInfo.handle_failure   s   ;&x00$ '*lnn#Aq##'X77 #s7H'IJJJ$$FCl' 	% 	
 	
 	
 	SVSXsz5AAA!!sv,/ch),,/,=(-	 	" 	/ 	/ 	/
 	c5)))r;   c           
         t          |j                  x}|_        t          |t                    r|j        x}|_        t          |          t          |j                  |j        |	                    d          pt          |j
                  |	                    d          pt          |j                  f\  }}}}}	t          |||          }
|j        |j        t          ||j                  ||||	|
j        |j        d	}t&                              |
j        |
j                                        ||
j        r|nd d|i           d S )Nargsrepr
kwargsrepr)	hostnamerx   ry   rP   r*   r   ro   r(   rJ   r5   )r{   r6   )r   r   rG   r   rP   r
   r   r*   r{   getr   ro   rQ   r   rx   rW   ry   r(   rJ   r7   logr)   r'   strip)r\   rB   rh   rO   eobjr   r*   r{   sargsskwargspolicyr9   s               r:   rm   zTraceInfo._log_error   sG   !6u!G!GGud233 	.%)X-D5?dOOU_%%NGGJ69SX#6#6GGL!!:Ysz%:%::
6	9hw  eT22 &!#ty11"!-

 

 	

6?FM$7$7$9$97(.(8BHHd '* 	 	, 	, 	, 	, 	,r;   rF   )FT)T)TT)__name__
__module____qualname____doc__	__slots__r]   rj   rp   rs   re   rg   rm    r;   r:   r    r       s        ++#I   
 7;3 3 3 3 4 4 44 4 4   0   <, , , , ,r;   r    c                 $   d }| 0t          | d          r| j        }n/t          j                    \  }}}nt          j                    \  }}}|B	 |j                                         |j        j         n# t          $ r Y nw xY w|j        }|@d S d S )Nr   )	hasattrr   rz   r{   tb_frameclearf_localsRuntimeErrortb_next)rP   r   r   s      r:   traceback_clearr     s     
B
3(( 	&"BB|~~HAq""<>>1b
.	KK    	 	 	D	 Z .....s   %A5 5
BBTFc                     	
 !"#$% t          d          rnj        |pj        }j        }j        % o	j        o| %r|s
j        rdn o| j        j        sj        oj        j	        oj
        j        pt                      j        j        |j        |j        d#d$d"t          d          rj        #t          d          rj        $t          d          rj        "t'          j                    j        }|j        |j        t0          j        t0          j        t2                              t6          j                  j        t<          j        j         t<          j!        j         t<          j"        j         !ddl#m$} |j%         tL          dffd		d	  !"#$
%fd
	}|S )a=  Return a function that traces task execution.

    Catches all exceptions and updates result backend with the
    state and result.

    If the call was successful, it saves the result to the task result
    backend, and sets the task status to `"SUCCESS"`.

    If the call raises :exc:`~@Retry`, it extracts
    the original exception, uses that as the result and sets the task state
    to `"RETRY"`.

    If the call results in an exception, it saves the exception as the task
    result, and sets the task state to `"FAILURE"`.

    Return a function that takes the following arguments:

        :param uuid: The id of the task.
        :param args: List of positional args to pass on to the function.
        :param kwargs: Keyword arguments mapping to pass on to the function.
        :keyword request: Request dict.

    __call__TNbefore_start
on_successafter_returnr   )canvasc                 t    r  ||          }|                     	| |          }|||j        |j        fS )N)ri   r`   )rj   rZ   r0   )
rU   rP   rZ   r`   IRInfori   	propagaterB   s
         r:   on_errorzbuild_tracer.<locals>.on_errory  sW     	D  'm ! 
 
 !QWah&&r;   c                    d x}x}x}x}x}}	d }
 $            }	 	 |j          n# t          $ r t          d          w xY wt          |pi |d|          }
|
j        o|
j                            dd          }r|r|
j        t          v r 6||||          S t          |
j                  }	 |j	        }	|	t          k    r:t          t          |
j        t          |
%          dd            6||||          S n# t          $ r Y nw xY w .2           |
j        p| }!r|
j                            d          nd } -|
           	 +rt!          2| 2||	            #| 2           7r&2j                            | ' d
t&          |
           	 4r 4| ||            |i |x}}t          }		 2j        j        }|rt-          2j        j                  dk    rg g }}|D ]O} 0|          }t/          |t0                    r|                    |           :|                    |           P|D ]}|                    |f| ||           |r)t1          |                              |f| ||           n+ 0|d                                       |f| ||           |
j        }|r: 0|                                          }|                    |f|| ||           2j                            | ||
,           t=          |/          } $            |z
  }5r 5|| ||           1rt?          2|           rnt          t@          | t          |
%          |||
                    d          ptC          |          |
                    d          ptC          |          d           np# tD          $ r} &|
|          \  }}}	}Y d }~nOd }~ww xY w# tF          $ r^} tH          |          tK          d          }}|j	        |j&        }}	|'                    2|
           tQ          |           Y d }~nd }~wtR          $ r^} tT          |          tK          d          }}|j	        |j&        }}	|+                    2|
           tQ          |           Y d }~n~d }~wtX          $ r2} &|
|tZ          d          \  }}}	}tQ          |           Y d }~nDd }~wt\          $ r*} &|
|          \  }}}	}tQ          |           Y d }~nd }~wt^          $ r  w xY w|	vr3r 3|	|| ||d            	 *rta          2| 2||||	            )              (             sr	 2j        1                                  "             n# td          tf          th          f$ r  t\          $ r(}tj          6                    d|d           Y d }~nd }~ww xY wn#  )              (             sp	 2j        1                                  "             w # td          tf          th          f$ r  t\          $ r'}tj          6                    d|d           Y d }~w d }~ww xY ww xY w# 	 *rta          2| 2||||	            )              (             sp	 2j        1                                  "             w # td          tf          th          f$ r  t\          $ r'}tj          6                    d|d           Y d }~w d }~ww xY ww #  )              (             sp	 2j        1                                  "             w # td          tf          th          f$ r  t\          $ r'}tj          6                    d|d           Y d }~w d }~ww xY ww xY wxY wn[# th          $ r  t\          $ rD}to          2| ||||           r tq          2|          }|
 &|
|          \  }}}}Y d }~nd }~ww xY w 6||||          S )Nz'Task keyword arguments is not a mappingF)r   called_directlyro   redeliveredappz$Task already completed successfully.)rx   ry   r(   priority)rv   r   rB   r   ro   )pidr   ru   r-   )	parent_idroot_idr   r   )chainr   r   r   )rv   resultr   r   )rx   ry   return_valuer2   r   ro   TrJ   )r`   )rv   r   rB   r   ro   r0   rZ   zProcess cleanup failed: %rr   )9itemsAttributeErrorr   r   delivery_infor   rx   r%   r   rZ   SUCCESSr1   LOG_IGNOREDrW   r   r   send_prerunr|   r   STARTEDrU   	callbackslenrG   r   appendapply_asyncr   popmark_as_doner   send_successLOG_SUCCESSr
   r   r   REJECTEDr   r0   rp   r   r   IGNOREDrs   r   rd   	ExceptionBaseExceptionsend_postrunprocess_cleanupKeyboardInterrupt
SystemExitMemoryErrorr7   error_signal_internal_errorreport_internal_error)8uuidr   ro   rU   r   r   TRstrr0   rZ   task_request
time_startr   rr   task_priorityr   sigsgroupssiggroup_r   _chsigrP   r   IGNORE_STATESr   
_does_infor   deduplicate_successful_tasksri   funr   inherit_parent_priorityloader_cleanuploader_task_init	monotonicry   r   r   pop_requestpop_taskpostrun_receiversprerun_receiverspublish_resultpush_request	push_taskresultrepr_maxsize	signaturesuccess_receiversrB   task_after_returntask_before_starttask_on_successr/   track_starteds8                            r:   r"   z build_tracer.<locals>.trace_task  s    -100A00D06EY[[
m	9?! ? ? ?&=? ? ?? #7=bt38I I IL (5 T+9==mUSS + 9 9?&999%:aAt444S9999GE ''["./$1,$E$E+Q+ +   
  *z!Q4888 ( +   D IdOOO"*2dG'2L6:::FFF-1 L&&&A8# :tT%)&: : : :  t,,,  L--cx@@' , .   [( >))$f===!$d!5f!5!55A#E*A %)L$:	$ ""4<#9::Q>>/12f+4 !9 !9C*3)CS*A*A*AC'1#u'='= %9(.c(:(:(:(:(,C(8(8(8(8.4 !& !&F$*$6$6)/	261> %7 %& %& %& %&
 $( !&$)$C$8$8$8$D$D)/	261> %E %& %& %& !*	)A,C @ @ @ L L%+Iw-: !M !" !" !" !- 2  %.Yuyy{{%D%D%DF"..!'	*.)6 /   
 11 &,    (+=>>%IKK*4* H+OFD$GGG, E(VDDDD%  &*(5lD(I(I04+,(4(8(8(D(D(W	RV*6*:*:<*H*H*]IV\L]L]/ /    ' J J J.6h|S.I.I+1eVVVVVVJI  ) ) )4#..t0L0L0LqA$%GQX6EOOD,777#C(((((((( ) ) )4--}d/K/K/KqA$%GQX6EOOD,777#C(((((((( ) ) )*2($c5+G +G +G'Aq%#C((((((((  ) ) )*2(<*E*E'Aq%#C(((((((($   N --( ))!64vt  8( A$D$T*.v,2%A A A A HJJJKMMM  88 L88:::*N,,,, 1:{K " " "!( 8 8 8"LL)Es26 ) 8 8 8 8 8 8 8 888 HJJJKMMM  88 L88:::*N,,,, 1:{K " " "!( 8 8 8"LL)Es26 ) 8 8 8 8 8 8 8 8888( A$D$T*.v,2%A A A A HJJJKMMM  88 L88:::*N,,,, 1:{K " " "!( 8 8 8"LL)Es26 ) 8 8 8 8 8 8 8 888 HJJJKMMM  88 L88:::*N,,,, 1:{K " " "!( 8 8 8"LL)Es26 ) 8 8 8 8 8 8 8 888  	 	 	 	9 	9 	9"4tVWcJJJ %dC00A'%XlC88
1a	9 z!Q4(((s  $ ^# >A^# ^# /C< 6A^# ;^# <
D	^# D		A ^# 
A
Y3  O( 6EN? B2Y3 ?
O%	O Y3  O%%Y3 (
T,2AQY3 T,AR1,Y3 1T,>(S+&Y3 +T,8 TY3 T,,Y3 W( ^# 5#V ^# !W#;W^# W##^# (Y0 #X$#Y0$!Y,Y'"Y0'Y,,Y00^# 3^5\^$#[^!\)\^\^^,#]^!^1^^^^^^# #_;7:_66_;rF   )'rD   runloaderra   r  rc   conftask_acks_late	acks_late#worker_deduplicate_successful_tasksr|   
persistentr   task_inherit_parent_priorityon_task_initon_process_cleanupr   r   r   osgetpidrequest_stackpushr   r   r7   isEnabledForloggingINFOr   r   task_prerun	receiverstask_postruntask_successceleryr   maybe_signaturerf   )&ry   rB   r  r   r_   r   ri   r   r   r   r/   r   ra   r  r   r"   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  s&   `` ` ```````    @@@@@@@@@@@@@@@@@@@@@@r:   r!   r!   &  s   B "$
33
A$$C!szF&M&MIL4#5#Km:KM  9] 9t'> 9"8='8%(X%<%N %?(+(T%?(+(> ! (;==H!hC*.NOt^,, . -t\** */t^,, . -
)++C&M %L#K IH$$W\22J0*4,6,6&I%,D ' ' ' ' ' ' ' ' '}) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) })~ r;   c           	      :   |si n|}	 | j         t          | j        | fi || _         |                      ||||          S # t          $ rQ}t	          | |||||           t          t          | |          t          t          |          dd          cY d}~S d}~ww xY w)zTrace task execution.Ng        )		__trace__r!   ry   r   r   r/   r   r    rf   )rB   r   r   ro   rU   optsrP   s          r:   r"   r"   D  s    ,bbWG`>!)$)TBBTBBDN~~dD&'::: ` ` `tT4#FFF/c::Igs<S<SUXZ^________`s   6? 
B	ABBBc           
         	 t          j                    \  }}}t                      }t          |j                  |_        t          |j                  |_        t          j        	                    | |||||||           ~dS # ~w xY w)zJSend a special `internal_error` signal to the app for outside body errors.)rv   r   r   ro   rU   r   r*   rO   N)
rz   r{   r   r   r   r   r   r   task_internal_errorr   )	rB   r   r   ro   rU   rP   r   r   rO   s	            r:   r   r   P  s    <>>1b25?CC)%*55
#(( 	) 		
 		
 		
 BBBs   A>B Bc                 B   |pt          j                    }d }	|r-t          |j        j                  }
 |||||
          \  }}}	n|\  }}}	t                      } |j        |||ddfi |	pi  t          |j        |          |||||          \  }}}}|rd||fnd||fS )NacceptFr   ro   r   is_eagerr   r-   r   )	r   _get_current_objectr	   r  accept_contentr   updater"   tasks)ry   r   rU   bodycontent_typecontent_encodingr   r   extra_requestembedr   r   ro   r   r   r   r   r   s                     r:   trace_task_retr,  e  s    
2022CE #'(?@@#e, 0
 
 
fee #fe}}HGN%    
"   sy#T67E E EMAq!T+Aq!994|+r;   c	                     |st           n|}d }
|\  }}}|r |||||          \  }}}
n|\  }}}
 |j        |||ddfi |
pi  ||                              ||||          \  }}}}|rd||fnd||fS )Nr  Fr!  r-   r   )
_localizedr%  r  )rB   r   rU   r'  r(  r)  r   _locr   r   r+  r&  r   r   ro   r   r   r   r   s                      r:   fast_trace_taskr0  {  s     "+::tDE"E68 ##e, 0
 
 
fee #feGN%    
"   $K))dFG MAq!T +Aq!994|+r;   c                    t          j                    \  }}}	 | j                            |d          }t	          |||fd          }t          t          d                    ||j                                       |~S # ~w xY w)NpickleTr   z'Exception raised outside body: {!r}:
{})	rz   r{   r|   prepare_exceptionr   r   RuntimeWarningr'   r*   )rB   rP   _type_value_tbr{   s         r:   r   r     s    E63//X>> %!5EEE^6==X') )* * 	+ 	+ 	+ CCs   A%B   Bc                    |pt                      }t                       |                                  |                                  |                                  | j        t          | j        j                  |gt          dd<   d| _
        dS )z#Setup worker related optimizations.NT)r   _install_stack_protectionset_currentset_defaultfinalize_tasksr	   r  r$  r.  use_fast_trace_task)r   r   s     r:   r#   r#     s    (;==H  OOOO LLNNN 	
sx677JqqqM #Cr;   c                     	 t          t          d           n# t          $ r Y nw xY w	 t                              d          t          _        n# t          $ r Y nw xY wd| _        dS )z*Reset previously configured optimizations._stackprotectedBaseTask.__call__FN)delattrr@   r   _patchedr   r   KeyErrorr>  r   s    r:   r$   r$     s    +,,,,   $LL)<==   #Cs    
%%$A 
AAc                      t          t          dd          s5t          j        xt          d<   fd} | t          _        dt          _        d S d S )Nr@  FrA  c                     | j         }|j        }|r5|j        s.t          |          dk    r|j        sd|_         | j        |i |S  | g|R i |S )Nr-   )r  top
_protectedr   r   r  )r\   r   ro   stackrh   origs        r:   __protected_call__z5_install_stack_protection.<locals>.__protected_call__  sw    &E)C 13> 1JJ!OOC,?O!"tx00004.t...v...r;   T)rT   r@   r   rC  r@  )rK  rJ  s    @r:   r9  r9    sh     8.66 (/7/@@$%	/ 	/ 	/ 	/ 	/ /#'   ( (r;   rF   )mr   r  r  rz   timecollectionsr   warningsr   billiard.einfor   r   kombu.exceptionsr   kombu.serializationr   loads_messager	   kombu.utils.encodingr
   r   r  r   r   r   r   celery._stater   celery.app.taskr   r   r@   celery.exceptionsr   r   r   r   r   celery.resultr   celery.utils.logr   celery.utils.nodenamesr   celery.utils.objectsr   celery.utils.safereprr   celery.utils.serializationr   r   r   __all__celery.worker.stater%   r   r7   LOG_RECEIVEDr   LOG_FAILURELOG_INTERNAL_ERRORr   LOG_REJECTEDr   r&   WARNrH   r  rI   CRITICALrK   rM   ERRORrN   r  r   r   r  r   r  r   r   r   r   r   rd   rf   EXCEPTION_STATES	frozensetr   r.  rC  r/   r1   rD   rQ   rW   r    r   r   r!   r"   r   r,  r0  r   r#   r$   r9  r   r;   r:   <module>rh     s   
  				 



  " " " " " "       @ @ @ @ @ @ @ @ ( ( ( ( ( ( 6 6 6 6 6 6 6 6 6 6 6 6 4 4 4 4 4 4 4 4 6 6 6 6 6 6 6 6 6 6 6 6 % % % % % % # # # # # # , , , , , , Z Z Z Z Z Z Z Z Z Z Z Z Z Z % % % % % % ' ' ' ' ' ' . . . . . . + + + + + + * * * * * * l l l l l l l l l l
 4 3 3 3 3 3	H		


 


	 z> 
 !Lz7<ANN  Liq!LL "l('*:Aq   #l"GL!Q   %$gmQ   !&#(#(
.
.
.?
.* 	7E8455 
Z&MNN
7 7 7: : :
% 
% 
%7 7 7p, p, p, p, p, p, p, p,f   , %)4du4>j,[ [ [ [|	` 	` 	` 	`  , ,9d, , , ,. -:!, , , ,,
 
 
# # # #< $/ 
$ 
$ 
$ 
$( ( ( ( (r;   