
    Zi                         d dl Z d dlZd dlmZmZmZmZ d dlmZ  ed          Z	 ed          Z
dee	eeee
f         f         dee	e
f         fdZ ed	          Zd
edefdZdS )    N)AnyCallable	CoroutineTypeVar)	ParamSpecPRfuncreturnc                       fd}|S )zA function decorator that converts an async function to a sync function.

    This should generally not be used in production code paths.
    c                  N   d }	 t          j                    }n7# t          $ r* t          j                    }t          j        |           Y nw xY w|                                r | i |S |                     | i |          }dt          dt          ffd |          S )Nresultr   c                     t          | t                    rfd| D             S t          | t                    rt          |           S t	          |           rt          |           S | S )Nc                 &    g | ]} |          S  r   ).0rconvert_results     Y/root/projects/butler/venv/lib64/python3.11/site-packages/chromadb/utils/async_to_sync.py
<listcomp>zOasync_to_sync.<locals>.sync_wrapper.<locals>.convert_result.<locals>.<listcomp>    s#    :::aq)):::    )
isinstancelistobjectasync_class_to_synccallableasync_to_sync)r   r   s    r   r   z;async_to_sync.<locals>.sync_wrapper.<locals>.convert_result   sr    &$'' ;::::6::::&&)) 3*6222 -$V,,,Mr   )asyncioget_event_loopRuntimeErrornew_event_loopset_event_loop
is_runningrun_until_completer   )argskwargsloopr   r   r
   s       @r   sync_wrapperz#async_to_sync.<locals>.sync_wrapper   s    	))++DD 	) 	) 	))++D"4(((((	) ?? 	)4((((((t)>v)>)>??
	3 
	3 
	 
	 
	 
	 
	 
	 ~f%%%s    1AAr   )r
   r(   s   ` r   r   r      s$    & & & & &6 r   Tclsc                     t          j        |           D ][\  }}t          |          rGt          j        |          r3|                    d          st          | |t          |                     \| S )zA decorator that converts a class with async methods to a class with sync methods.

    This should generally not be used in production code paths.
    __)inspect
getmembersr   iscoroutinefunction
startswithsetattrr   )r*   attrvalues      r   r   r   2   s{    
 )#.. 5 5eUOO	5+E22	5 OOD))	5
 C}U33444Jr   )r-   r   typingr   r   r   r   typing_extensionsr   r   r	   r   r)   r   r   r   r   <module>r6      s      4 4 4 4 4 4 4 4 4 4 4 4 ' ' ' ' ' ' IcNNGCLL!Ic3k$:!:; !A ! ! ! !H GCLLQ 1      r   