
    Ng                     f    d Z ddlmZ ddlZ ej        e          Zd Z G d de          Z	d Z
dS )zFA thread pool that logs exceptions raised by tasks executed within it.    )futuresNc                       fd}|S )z:Wraps an arbitrary callable behavior in exception-logging.c                  j    	  | i |S # t           $ r t                              d            w xY w)Nz6Unexpected exception from %s executed in logging pool!)	Exception_LOGGER	exception)argskwargsbehaviors     b/var/www/html/ai-engine/env/lib/python3.11/site-packages/grpc/framework/foundation/logging_pool.py	_wrappingz_wrap.<locals>._wrapping   s[    	8T,V,,, 	 	 	H   	s    '2 )r   r   s   ` r   _wrapr      s$             c                   8    e Zd ZdZd Zd Zd Zd Zd Zd
dZ	d	S )_LoggingPoolzGAn exception-logging futures.ThreadPoolExecutor-compatible thread pool.c                     || _         d S N)_backing_pool)selfbacking_pools     r   __init__z_LoggingPool.__init__)   s    )r   c                     | S r   r   )r   s    r   	__enter__z_LoggingPool.__enter__,   s    r   c                 <    | j                             d           d S )NTwaitr   shutdown)r   exc_typeexc_valexc_tbs       r   __exit__z_LoggingPool.__exit__/   "    ###.....r   c                 H     | j         j        t          |          g|R i |S r   )r   submitr   )r   fnr	   r
   s       r   r&   z_LoggingPool.submit2   s.    (t!(rDTDDDVDDDr   c                 p     | j         j        t          |          g|R d|                    dd           iS )Ntimeout)r   mapr   get)r   func	iterablesr
   s       r   r*   z_LoggingPool.map5   sM    %t!%$KK
#
 
 
-3ZZ	4-H-H
 
 	
r   Tc                 <    | j                             |           d S )Nr   r   )r   r   s     r   r   z_LoggingPool.shutdown:   r$   r   N)T)
__name__
__module____qualname____doc__r   r   r#   r&   r*   r   r   r   r   r   r   &   s|        QQ* * *  / / /E E E
 
 

/ / / / / /r   r   c                 D    t          t          j        |                     S )a1  Creates a thread pool that logs exceptions raised by the tasks within it.

    Args:
      max_workers: The maximum number of worker threads to allow the pool.

    Returns:
      A futures.ThreadPoolExecutor-compatible thread pool that logs exceptions
        raised by the tasks executed within it.
    )r   r   ThreadPoolExecutor)max_workerss    r   poolr6   >   s     2;??@@@r   )r2   
concurrentr   logging	getLoggerr/   r   r   objectr   r6   r   r   r   <module>r;      s    M L       
'
H
%
%   / / / / /6 / / /0
A 
A 
A 
A 
Ar   