
    ug                         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y)    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                  6   d }	 t        j                         }|j                         r | i |S |j                   | i |      }dt        dt        ffd |      S # t        $ r, t        j                         }t        j                  |       Y }w xY w)Nresultr   c                     t        | t              r| D cg c]
  } |       c}S t        | t              rt        |       S t	        |       rt        |       S | S c c}w )N)
isinstancelistobjectasync_class_to_synccallableasync_to_sync)r   rconvert_results     Q/var/www/openai/venv/lib/python3.12/site-packages/chromadb/utils/async_to_sync.pyr   z;async_to_sync.<locals>.sync_wrapper.<locals>.convert_result   sY    &$'39:6aq)6::&&)*622$V,,M ;s   A)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    	)))+D
 ??(((((t)>v)>?
	3 
	3 
	 f%%+  	)))+D""4(	)s   A# #2BB )r
   r#   s   ` r   r   r      s    &6     Tclsc                     t        j                  |       D ]O  \  }}t        |      st        j                  |      s(|j	                  d      r:t        | |t        |             Q | 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   sV    
 ))#.eUO++E2OOD)C}U34 / Jr%   )r*   r   typingr   r   r   r   typing_extensionsr   r   r	   r   r&   r   r$   r%   r   <module>r3      sw      4 4 ' cNCL!Ic3k$:!:; !A !H CLQ 1 r%   