§
    ÒÁ³g.  ã                  óØ   — d dl mZ d dlZd dlZd dlZd dlZd dlmZmZm	Z	m
Z
 d dlmZ d dlZd dlZd dlZ ed¦  «        Z ed¦  «        Zej        dk    rej        Zndd„Zdd„Zdd„ZdS )é    )ÚannotationsN)ÚAnyÚTypeVarÚCallableÚ	Awaitable)Ú	ParamSpecÚT_RetvalÚT_ParamSpec)é   é	   ÚfuncúCallable[T_ParamSpec, T_Retval]ÚargsúT_ParamSpec.argsÚkwargsúT_ParamSpec.kwargsÚreturnr   c             �  óÖ   K  — t           j                             ¦   «         }t          j        ¦   «         }t          j        |j        | g|¢R i |¤Ž}|                     d|¦  «        ƒ d{V —†S )aŸ  Asynchronously run function *func* in a separate thread.

        Any *args and **kwargs supplied for this function are directly passed
        to *func*. Also, the current :class:`contextvars.Context` is propagated,
        allowing context variables from the main thread to be accessed in the
        separate thread.

        Returns a coroutine that can be awaited to get the eventual result of *func*.
        N)	ÚasyncioÚeventsÚget_running_loopÚcontextvarsÚcopy_contextÚ	functoolsÚpartialÚrunÚrun_in_executor)r   r   r   ÚloopÚctxÚ	func_calls         úQ/var/www/html/mpstechhub/venv/lib/python3.11/site-packages/openai/_utils/_sync.pyÚ_asyncio_to_threadr"      su   è è € õ Œ~×.Ò.Ñ0Ô0ˆÝÔ&Ñ(Ô(ˆÝÔ% c¤g¨tÐE°dÐEÐEÐE¸fÐEÐEˆ	Ø×)Ò)¨$°	Ñ:Ô:Ð:Ð:Ð:Ð:Ð:Ð:Ð:ó    c             �  óÐ   K  — t          j        ¦   «         dk    rt          | g|¢R i |¤Žƒ d {V —†S t          j                             t          j        | g|¢R i |¤Ž¦  «        ƒ d {V —†S )Nr   )ÚsniffioÚcurrent_async_libraryr"   ÚanyioÚ	to_threadÚrun_syncr   r   )r   r   r   s      r!   r(   r(   )   s¢   è è € õ Ô$Ñ&Ô&¨)Ò3Ð3Ý'¨Ð>¨tÐ>Ð>Ð>°vÐ>Ð>Ð>Ð>Ð>Ð>Ð>Ð>Ð>å”×)Ò)ÝÔ˜$Ð0 Ð0Ð0Ð0¨Ð0Ð0ñô ð ð ð ð ð ð ð r#   Úfunctionú*Callable[T_ParamSpec, Awaitable[T_Retval]]c                ó   ‡ — dˆ fd„}|S )	aP  
    Take a blocking function and create an async one that receives the same
    positional and keyword arguments. For python version 3.9 and above, it uses
    asyncio.to_thread to run the function in a separate thread. For python version
    3.8, it uses locally defined copy of the asyncio.to_thread function which was
    introduced in python 3.9.

    Usage:

    ```python
    def blocking_func(arg1, arg2, kwarg1=None):
        # blocking code
        return result


    result = asyncify(blocking_function)(arg1, arg2, kwarg1=value1)
    ```

    ## Arguments

    `function`: a blocking regular callable (e.g. a function)

    ## Return

    An async function that takes the same positional and keyword arguments as the
    original one, that when called runs the same original function in a thread worker
    and returns the result.
    r   r   r   r   r   r	   c               Ÿ  ó4   •K  — t          ‰g| ¢R i |¤Žƒ d {V —†S )N)r(   )r   r   r*   s     €r!   Úwrapperzasyncify.<locals>.wrapperS   s7   øè è € Ý˜xÐ9¨$Ð9Ð9Ð9°&Ð9Ð9Ð9Ð9Ð9Ð9Ð9Ð9Ð9r#   )r   r   r   r   r   r	   © )r*   r.   s   ` r!   Úasyncifyr0   5   s(   ø€ ð<:ð :ð :ð :ð :ð :ð €Nr#   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r	   )r*   r   r   r+   )Ú
__future__r   Úsysr   r   r   Útypingr   r   r   r   Útyping_extensionsr   r'   r%   Úanyio.to_threadr	   r
   Úversion_infor(   r"   r0   r/   r#   r!   ú<module>r7      s  ðØ "Ð "Ð "Ð "Ð "Ð "à 
€
€
€
Ø €€€Ø Ð Ð Ð Ø Ð Ð Ð Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'à €€€Ø €€€Ø Ð Ð Ð àˆ7�:ÑÔ€Øˆi˜Ñ&Ô&€ð Ô�vÒÐØ Ô*ÐÐð;ð ;ð ;ð ;ð$ð ð ð ð!ð !ð !ð !ð !ð !r#   