Ë
    $Æ%h.  ã                  óü   — 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y)é    )ÚannotationsN)ÚAnyÚTypeVarÚCallableÚ	Awaitable)Ú	ParamSpecÚT_RetvalÚT_ParamSpec)é   é	   c             �  óî   K  — t         j                  j                  «       }t        j                  «       }t        j                  |j                  | g|¢­i |¤Ž}|j                  d|«      ƒ d{  –—† S 7 Œ­w)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)ÚfuncÚargsÚkwargsÚloopÚctxÚ	func_calls         úQ/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/openai/_utils/_sync.pyÚ_asyncio_to_threadr      sa   è ø€ ô �~‰~×.Ñ.Ó0ˆÜ×&Ñ&Ó(ˆÜ×%Ñ% c§g¡g¨tÐE°dÒE¸fÑEˆ	Ø×)Ñ)¨$°	Ó:×:Ð:Ð:ús   ‚A,A5Á.A3Á/A5c             �  óê   K  — t        j                  «       dk(  rt        | g|¢­i |¤Žƒ d {  –—† S t        j                  j                  t        j                  | g|¢­i |¤Ž«      ƒ d {  –—† S 7 ŒB7 Œ­w)Nr   )ÚsniffioÚcurrent_async_libraryr   ÚanyioÚ	to_threadÚrun_syncr   r   )r   r   r   s      r   r#   r#   )   sp   è ø€ ô ×$Ñ$Ó&¨)Ò3Ü'¨Ð>¨tÒ>°vÑ>×>Ð>ä—‘×)Ñ)Ü×Ñ˜$Ð0 Ò0¨Ñ0ó÷ ð ð ?øðús!   ‚*A3¬A/­=A3Á*A1Á+A3Á1A3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.
    c               Ÿ  ó>   •K  — t        ‰g| ¢­i |¤Žƒ d {  –—† S 7 Œ­w)N)r#   )r   r   Úfunctions     €r   Úwrapperzasyncify.<locals>.wrapperS   s"   øè ø€ Ü˜xÐ9¨$Ò9°&Ñ9×9Ð9Ð9ús   ƒ–—)r   úT_ParamSpec.argsr   úT_ParamSpec.kwargsÚreturnr	   © )r'   r(   s   ` r   Úasyncifyr-   5   s   ø€ õ<:ð €Nó    )r   úCallable[T_ParamSpec, T_Retval]r   r)   r   r*   r+   r   )r   r/   r   r)   r   r*   r+   r	   )r'   r/   r+   z*Callable[T_ParamSpec, Awaitable[T_Retval]])Ú
__future__r   Úsysr   r   r   Útypingr   r   r   r   Útyping_extensionsr   r"   r    Úanyio.to_threadr	   r
   Úversion_infor#   r   r-   r,   r.   r   ú<module>r6      s¥   ðÝ "ã 
Û Û Û ß 4Ó 4Ý 'ã Û Û á�:Ó€Ù˜Ó&€ð ×Ñ�vÒØ ×*Ñ*Ñð;Ø-ð;Ø9Ið;ØUgð;à	ó;ð$Ø
)ðØ5EðØQcðàóô!r.   