
    `f*                         d Z ddlZddlZddlmZ ddlmZmZ ddlm	Z	 ddl
mZ  ed          Zd	Zd
ZdZ  e	de          ej                  ZdZd Zd ZddZd Zd Zd ZddZ eedd          ZddZdS )zWorker name utilities.    N)partial)ExchangeQueue   )memoize)simple_formatzC.dq2z{hostname}.dq2@celery)Cache)worker_directgethostnamenodenameanon_nodename	nodesplitdefault_nodenamenode_formathost_formatc                     t          | t                    r| S t          t                              |           t          |           S )a5  Return the :class:`kombu.Queue` being a direct route to a worker.

    Arguments:
        hostname (str, ~kombu.Queue): The fully qualified node name of
            a worker (e.g., ``w1@example.com``).  If passed a
            :class:`kombu.Queue` instance it will simply return
            that instead.
    hostname)
isinstancer   WORKER_DIRECT_QUEUE_FORMATformatWORKER_DIRECT_EXCHANGEr   s    H/var/www/html/env/lib/python3.11/site-packages/celery/utils/nodenames.pyr   r      sG     (E"" "))8)<<      c                 :    t                               | |f          S )z)Create node name from name/hostname pair.)NODENAME_SEPjoin)namer   s     r   r   r   1   s    dH-...r   genc           	          t          d                    |t          t          j                              g          | pt                                S )zsReturn the nodename for this process (not a worker).

    This is used for e.g. the origin task message field.
     )r   r   strosgetpidr   )r   prefixs     r   r   r   6   sC    
 BGGVS%5%5677-/ / /r   c                 v    |                      t          d          }t          |          dk    r
d|d         fS |S )z,Split node name into tuple of name/hostname.r   Nr   )splitr   len)r    partss     r   r   r   ?   s7    JJ|Q''E
5zzQU1X~Lr   c                 t    t          | pd          \  }}t          |pt          |pt                                S )z-Return the default nodename for this process.r#   )r   r   NODENAME_DEFAULTr   )r   r    hosts      r   r   r   G   s6    8>r**JD$D,,d.CkmmDDDr   c                 V    t          |          \  }}t          | ||pt          fd|i|S )z(Format worker node name (name@host.com).p)r   r   r-   )sr    extra	shortnamer.   s        r   r   r   M   sK    ooOIt	4..A A26A:?A A Ar   r#   0c                 6    ddl m}  |            }|r|  | n|S )Nr   )current_process_index)logr6   )r'   defaultr6   indexs       r   _fmt_process_indexr:   T   s=    ******!!##E!&3feG3r   -c                     |pt                      }|                    d          \  }}}|p|}t          |||t          t          dfi |}t          | |          S )zFormat host %x abbreviations..)hndiI)r   	partitiondictr:   _fmt_process_index_with_prefixr   )r1   r.   r    r2   hname_domainkeyss           r   r   r   ]   sx     ;==D~~c**E1f=5D6&D    
 D D!!!r   )Nr!   )r#   r4   )NN)__doc__r%   socket	functoolsr   kombu.entityr   r   
functionalr   textr   r   r   r   r-   rD   r   __all__r   r   r   r   r   r   r:   rE   r    r   r   <module>rR      sh     				        ( ( ( ( ( ( ( (             "'**  .   $ggat$$$V%788  $/ / /
/ / / /  E E EA A A4 4 4 4 "));S"!E!E 	" 	" 	" 	" 	" 	"r   