o
    bi                     @   s   d Z ddlZddlZddlmZ zddlZW n ey!   dZY nw dd Zdd Zde	fd	d
Z
edddede	fddZedddd ZdS )zj
This file should only be imported from Python 3.
It will raise SyntaxError when importing from Python 2.
    N)	lru_cachec                   C   s   t rt  S t S )z<Construct a new event loop. Ray will use uvloop if it exists)uvloopnew_event_loopasyncio r   r   M/home/ubuntu/.local/lib/python3.10/site-packages/ray/_private/async_compat.pyget_new_event_loop   s   r   c                   C   s   t rt   dS 	 dS )zGInstalls uvloop as event-loop implementation for asyncio (if available)N)r   installr   r   r   r   try_install_uvloop   s   r
   returnc                 C   s   t | p	t | S )zBReturn True if the function is an async or async generator method.)inspectiscoroutinefunctionisasyncgenfunctionfuncr   r   r   is_async_func   s   r   i   )maxsizeclsc                 C   s   t tj| tddkS )z/Return True if the class has any async methods.)	predicater   )lenr   
getmembersr   )r   r   r   r   has_async_methods$   s   r   c                    s   t  r S  fdd}|S )z-Wrap a blocking function in an async functionc                     s    | i |S )Nr   )argskwargsr   r   r   wrapper1   s   zsync_to_async.<locals>.wrapper)r   )r   r   r   r   r   sync_to_async*   s   r   )__doc__r   r   	functoolsr   r   ImportErrorr   r
   boolr   objectr   r   r   r   r   r   <module>   s     