
    g                     b    d Z ddlmZ ddlZ ej                  e      Zd Z G d de      Z	d Z
y)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                  ^    	  | i |S # t         $ r t        j                  d        w xY w)Nz6Unexpected exception from %s executed in logging pool!)	Exception_LOGGER	exception)argskwargsbehaviors     /var/www/html/FastMealFinder_FlaskServer-InitialRelease/venv/lib/python3.12/site-packages/grpc/framework/foundation/logging_pool.py	_wrappingz_wrap.<locals>._wrapping   s@    	T,V,, 	H 	s    !, )r   r   s   ` r   _wrapr      s         c                   6    e Zd ZdZd Zd Zd Zd Zd Zd	dZ	y)
_LoggingPoolzGAn exception-logging futures.ThreadPoolExecutor-compatible thread pool.c                     || _         y 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                   j                  d       y )NTwaitr   shutdown)r   exc_typeexc_valexc_tbs       r   __exit__z_LoggingPool.__exit__/       ###.r   c                 T     | j                   j                  t        |      g|i |S r   )r   submitr   )r   fnr	   r
   s       r   r&   z_LoggingPool.submit2   s)    (t!!((rDTDVDDr   c                 t     | j                   j                  t        |      g|d|j                  dd       iS )Ntimeout)r   mapr   get)r   func	iterablesr
   s       r   r*   z_LoggingPool.map5   s?    %t!!%%$K
#
-3ZZ	4-H
 	
r   c                 <    | j                   j                  |       y )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*/E

/r   r   c                 >    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2;?@@r   )r2   
concurrentr   logging	getLoggerr/   r   r   objectr   r6   r   r   r   <module>r;      s:    M  
'

H
% /6 /0
Ar   