
    uYf                         d dl Z d dlZd dlZd dlZddlmZ  G d dej                        Z G d de      Z	 ej                  d	       G d
 de j                               Zy)    N   )forksafec                       e Zd ZdZdZdZy)ServiceStatuszA Service status.stoppedrunningN)__name__
__module____qualname____doc__STOPPEDRUNNING     X/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/ddtrace/internal/service.pyr   r   
   s    GGr   r   c                        e Zd Z fdZ xZS )ServiceStatusErrorc                 l    || _         t        t        |   |j                  d|j
                         y )Nz is already in status )current_statussuperr   __init__r	   value)selfservice_clsr   	__class__s      r   r   zServiceStatusError.__init__   s1     - $0,7,@,@.BVBVW	
r   )r	   r
   r   r   __classcell__)r   s   @r   r   r      s    	
 	
r   r   F)eqc                       e Zd ZdZ ej
                  ej                  edd      Z ej
                  e	j                  ddd      Zd Zd Zd Zej                   d        Zd	 Zej                   d
        Z	 ddZy)Servicez)A service that can be started or stopped.F)defaulttypeinitr   )factoryreprr"   r   c                 &    | j                          | S N)start)r   s    r   	__enter__zService.__enter__%   s    

r   c                 D    | j                          | j                          y r&   )stopjoin)r   exc_type	exc_value	tracebacks       r   __exit__zService.__exit__)   s    				r   c                    | j                   5  | j                  t        j                  k(  r t	        | j
                  | j                         | j                  |i | t        j                  | _        ddd       y# 1 sw Y   yxY w)zStart the service.N)_service_lockstatusr   r   r   r   _start_servicer   argskwargss      r   r'   zService.start-   sk      	0{{m333(EED00'//DK		0 	0 	0   A%A;;Bc                      y)zStart the service for real.

        This method uses the internal lock to be sure there's no race conditions and that the service is really started
        once start() returns.

        Nr   r4   s      r   r3   zService._start_service<       r   c                    | j                   5  | j                  t        j                  k(  r t	        | j
                  | j                         | j                  |i | t        j                  | _        ddd       y# 1 sw Y   yxY w)zStop the service.N)r1   r2   r   r   r   r   _stop_servicer4   s      r   r*   zService.stopJ   sk      	0{{m333(EED//'//DK		0 	0 	0r7   c                      y)zStop the service for real.

        This method uses the internal lock to be sure there's no race conditions and that the service is really stopped
        once start() returns.

        Nr   r4   s      r   r;   zService._stop_serviceW   r9   r   Nc                      y)zJoin the service once stopped.Nr   )r   timeouts     r   r+   zService.joine   r9   r   r&   )r	   r
   r   r   attribr   r   r2   r   Lockr1   r(   r/   r'   abcabstractmethodr3   r*   r;   r+   r   r   r   r   r      s    3TWW]22UW\]FDGGHMMEeTM0 	 0 	  -r   r   )	metaclass)rB   enumtypingr?    r   Enumr   RuntimeErrorr   sABCMetar   r   r   r   <module>rL      s]    
    DII 

 

 5K- K- K-r   