
    Vh	                    J    d dl mZ d dlZd dlmZ dZdZ G d de      Z	ddZ
y)    )annotationsN
   c                      e Zd Zy)TimeoutErrorN)__name__
__module____qualname__     R/home/dcms/DCMS/lib/python3.12/site-packages/ansible/module_utils/facts/timeout.pyr   r      s    r   r   c                D      fd}t               r }d  ||      S |S )z
    Timeout decorator to expire after a set number of seconds.  This raises an
    ansible.module_utils.facts.TimeoutError if the timeout is hit before the
    function completes.
    c                      fd}|S )Nc                 ~   }|!t               j                  d      xs t        }t        j                  d      }|j                  | |      }|j                          	 |j                  |      |j                          S # t        j                  $ r t         d| d      w xY w# |j                          w xY w)NGATHER_TIMEOUT   )	processesz after z seconds)
globalsgetDEFAULT_GATHER_TIMEOUTmp
ThreadPoolapply_asyncclose	terminatemultiprocessingr   )argskwargstimeout_valuepoolreserror_messagefuncsecondss        r   wrapperz+timeout.<locals>.decorator.<locals>.wrapper'   s    #M$ '	.> ? YCY==1-D""4v6CJJL!ww}-
  	 #// U"m_GM?(#STTU  s   !B %B''B* *B<r
   )r"   r$   r!   r#   s   ` r   	decoratorztimeout.<locals>.decorator&   s    	!  r   N)callable)r#   r!   r%   r"   s   ``  r   timeoutr'       s.    . 
 r   )NzTimer expired)
__future__r   r   multiprocessing.poolr   r   r   r   	Exceptionr   r'   r
   r   r   <module>r+      s.     #  !
  	9 	%r   