
    gO              	           d Z ddlmZ ddlZddlZddlZddlZ ej                  e      Z	 G d de      Z
 G d d ej                  dg d      e
      Zd	 Zd
 Zd Zy)z%Utilities for working with callables.    )ABCNc                   X    e Zd ZdZej
                   G d dej                               Zy)Outcomea  A sum type describing the outcome of some call.

    Attributes:
      kind: One of Kind.RETURNED or Kind.RAISED respectively indicating that the
        call returned a value or raised an exception.
      return_value: The value returned by the call. Must be present if kind is
        Kind.RETURNED.
      exception: The exception raised by the call. Must be present if kind is
        Kind.RAISED.
    c                   ,    e Zd ZdZ e       Z e       Zy)Outcome.Kindz8Identifies the general kind of the outcome of some call.N)__name__
__module____qualname____doc__objectRETURNEDRAISED     /var/www/html/FastMealFinder_FlaskServer-InitialRelease/venv/lib/python3.12/site-packages/grpc/framework/foundation/callable_util.pyKindr   %   s    F8r   r   N)r   r	   r
   r   enumuniqueEnumr   r   r   r   r   r      s*    	 
[[tyy  r   r   c                       e Zd ZdZy)_EasyOutcomez$A trivial implementation of Outcome.N)r   r	   r
   r   r   r   r   r   r   -   s     /r   r   )kindreturn_value	exceptionc                     	 t        t        j                  j                   | |i |d       S # t        $ rD}t
        j                  |       t        t        j                  j                  d |      cY d }~S d }~ww xY wN)r   r   r   r   	Exception_LOGGERr   r   )behaviormessageargskwargses        r   _call_logging_exceptionsr$   6   sh    :LL!!8T#<V#<d
 	
  :'"GLL//q99:s   *- 	A:9A5/A:5A:c                 F     t        j                          fd       }|S )a  Wraps a callable in a try-except that logs any exceptions it raises.

    Args:
      behavior: Any callable.
      message: A string to log if the behavior raises an exception.

    Returns:
      A callable that when executed invokes the given behavior. The returned
        callable takes the same arguments as the given behavior but returns a
        future.Outcome describing whether the given behavior returned a value or
        raised an exception.
    c                  $    t        g| i |S r   r$   )r!   r"   r   r    s     r   wrapped_behaviorz0with_exceptions_logged.<locals>.wrapped_behaviorN   s    ''KDKFKKr   )	functoolswraps)r   r    r(   s   `` r   with_exceptions_loggedr+   @   s*     __XL L r   c                 "    t        | |g|i |S )a  Calls a behavior in a try-except that logs any exceptions it raises.

    Args:
      behavior: Any callable.
      message: A string to log if the behavior raises an exception.
      *args: Positional arguments to pass to the given behavior.
      **kwargs: Keyword arguments to pass to the given behavior.

    Returns:
      An Outcome describing whether the given behavior returned a value or raised
        an exception.
    r'   )r   r    r!   r"   s       r   call_logging_exceptionsr-   U   s     $HgGGGGr   )r   abcr   collectionsr   r)   logging	getLoggerr   r   r   
namedtupler   r$   r+   r-   r   r   r   <module>r3      sl    ,     
'

H
%c (/K= 	/:*Hr   