
    sj                     8    d dl Z d dlZddlmZ d Zd ZdddZy)    N   )checkURIc                       fd}|S )z0
    Decorator for RPC procedure endpoints.
    c                     t        |       sJ t        | d      sg | _        | j                  j                  dt	              i       | S )N_wslinkurisuri)callablehasattrr   appendr   )fr   s    8/DATA/.local/lib/python3.12/site-packages/wslink/core.pydecoratezregister.<locals>.decorate   s@    {{q-(AM	eXc]34     )r   r   s   ` r   registerr      s    
 Or   c                     	 t        j                         }|j                  | t        j                  |g|i |      S # t        $ r, t        j                         }t        j                  |       Y ]w xY w)a	  
    Schedule callback (which is passed args and kwargs) to be called on
    running event loop after delay seconds (can be floating point).  Returns
    asyncio.TimerHandle on which cancel() can be called to cancel the
    eventual invocation of the callback.
    )asyncioget_event_loopRuntimeErrornew_event_loopset_event_loop
call_later	functoolspartial)delaycallbackargskwargsloops        r   schedule_callbackr    !   sj    %%%' ??5)"3"3H"Nt"Nv"NOO  %%%'t$%s   ? 2A43A4)done_callbackc                ,   	 t        j                         }t        j                  |g|i ||j                  | fd      S |j                  | fd      S # t        $ r, t        j                         }t        j                  |       Y zw xY w)a  
    Creates a coroutine out of the provided coroutine function coro_func and
    the provided args and kwargs, then schedules the coroutine to be called
    on the running event loop after delay seconds (delay can be float or int).

    Returns asyncio.Task on which cancel() can be called to cancel the running
    of the coroutine.

    The coro_func parameter should not be a coroutine, but rather a coroutine
    function (a function defined with async).  The reason for this is we want
    to defer creation of the actual coroutine until we're ready to schedule it
    with "ensure_future".  Otherwise every time we cancel a TimerTask
    returned by "call_later", python prints "RuntimeWarning: coroutine
    '<coro-name>' was never awaited".
    c                  V    t        j                                 j                        S N)r   ensure_futureadd_done_callback)coro_partialr!   s   r   <lambda>z$schedule_coroutine.<locals>.<lambda>N   s     G)),.9KKr   c                  8    t        j                                 S r$   )r   r%   )r'   s   r   r(   z$schedule_coroutine.<locals>.<lambda>R   s    '*?*?*Or   )r   r   r   r   r   r   r   r   )r   	coro_funcr!   r   r   r   r'   s     `   @r   schedule_coroutiner+   4   s    "%%%' $$Y@@@L 
 	
 ??5"OPP  %%%'t$%s   A 2BB)r   r   r   r   r   r    r+   r   r   r   <module>r,      s%      4P& ?C Qr   