
    ,h0                     D    d dl mZmZ d dlmZ d dlmZ d Zd	dddddZy)
    )get_event_loopiscoroutine)wraps)	signaturec                 L   K    | |i |}t        |      r| d{    yy7 w)aT  
    This helper function launches an async main function that was tagged with
    forever=True. There are two possibilities:

    - The function is a normal function, which handles initializing the event
      loop, which is then run forever
    - The function is a coroutine, which needs to be scheduled in the event
      loop, which is then run forever
      - There is also the possibility that the function is a normal function
        wrapping a coroutine function

    The function is therefore called unconditionally and scheduled in the event
    loop if the return value is a coroutine object.

    The reason this is a separate function is to make absolutely sure that all
    the objects created are garbage collected after all is said and done; we
    do this to ensure that any exceptions raised in the tasks are collected
    ASAP.
    N)r   )coroargskwargsloopthings        j/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/setuptools/_vendor/autocommand/autoasync.py_run_forever_coror      s.     4 $!&!E5 s   $"$NFr   forever	pass_loopc                      fdS r<t               j                  d j                  j                         D              t	                fd       }r|_        |S )ak  
    Convert an asyncio coroutine into a function which, when called, is
    evaluted in an event loop, and the return value returned. This is intented
    to make it easy to write entry points into asyncio coroutines, which
    otherwise need to be explictly evaluted with an event loop's
    run_until_complete.

    If `loop` is given, it is used as the event loop to run the coro in. If it
    is None (the default), the loop is retreived using asyncio.get_event_loop.
    This call is defered until the decorated function is called, so that
    callers can install custom event loops or event loop policies after
    @autoasync is applied.

    If `forever` is True, the loop is run forever after the decorated coroutine
    is finished. Use this for servers created with asyncio.start_server and the
    like.

    If `pass_loop` is True, the event loop object is passed into the coroutine
    as the `loop` kwarg when the wrapper function is called. In this case, the
    wrapper function's __signature__ is updated to remove this parameter, so
    that autoparse can still be used on it without generating a parameter for
    `loop`.

    This coroutine can be called with ( @autoasync(...) ) or without
    ( @autoasync ) arguments.

    Examples:

    @autoasync
    def get_file(host, port):
        reader, writer = yield from asyncio.open_connection(host, port)
        data = reader.read()
        sys.stdout.write(data.decode())

    get_file(host, port)

    @autoasync(forever=True, pass_loop=True)
    def server(host, port, loop):
        yield_from loop.create_server(Proto, host, port)

    server('localhost', 8899)

    c                 "    t        |       S )Nr   )	autoasync)cr   r   r   s    r   <lambda>zautoasync.<locals>.<lambda>c   s    D!     c              3   0   K   | ]  \  }}|d k7  r|  yw)r   N ).0nameparams      r   	<genexpr>zautoasync.<locals>.<genexpr>n   s#      .!dEv~ .s   )
parametersc            	      r   
t               n}	r`j                         } |j                  j                  dd|i j                  | i |j                   |j
                  |j                  }} r.|j                  t        | ||             |j                          y |j                   | i |      S )Nr   r   )r   bind_partial	argumentsupdatebindr	   r
   create_taskr   run_foreverrun_until_complete)
r	   r
   
local_loop
bound_argsr   r   r   new_sigold_sigr   s
       r   autoasync_wrapperz$autoasync.<locals>.autoasync_wrapperr   s     *.^%4
  --/J'J  '' ;;',,//99; &??J,=,=&D""#4dFJ$  ""$00t1Fv1FGGr   )r   replacer   itemsr   __signature__)r   r   r   r   r+   r)   r*   s   ```` @@r   r   r   6   s    X |! 	! D/// .%,%7%7%=%=%?./   4[H H H0 *1'r   )N)	asyncior   r   	functoolsr   inspectr   r   r   r   r   r   <module>r2      s'   $ 0  >Xu Xr   